Serial port access from xml code

Good evening everyone.

I have been using the Microsoft windows macros with speech recognition for years for my AI which controls my home automation (through many years of adding possible responses she is now quite realistic). You say something it reacts and then accesses 'BitSophia' and outputs to the Arduino which fires a relay which switches on a light or some other attachment.

I have started rewriting the system to be more efficient by having one macro which controls everything (and want to disregard Bitsophia completely and call the output directly), all is going well and she seems to be more responsive, faster and more effective, but for the life of me I cannot output to the serial port to control the Arduino from XML language.

Can anyone help with a simple way of outputting a simple 1, 2 3 etc. to the serial port which I can then use a sketch to interpret on the arduino) from XML? Is there a way of creating a shortcut which will output the serial port from windows? I could then call upon this shortcut in my xml code? Happy for all and any suggestions - clutching at straws a little here and would appreciate your help.

Graeme

Do you understand what is XML ?

If so, have you written such a file?

To the best of my knowledge XML is just a text file. How can it be expected to output to a serial port?

You need to write a program to read and make sense of the XML file and send the relevant data to the Arduino.

For receiving the data on the Arduino you may be interested in Serial Input Basics

...R

XML is a markup language, it is not a programming language.

An XML file itself can't do anything, it's just text. Of course, many pieces of software use XML to store data (and even code).

You should refer to documentation for whatever software you're feeding the XML to, to determine how to use the serial port from that.

Thanks everyone. Perhaps my description was a bit vague. Windows speech recognition uses XML to store the text that is the instruction as to what to do when a word or phrase is heard. I understand that it is not a language per se, but in this context it is where the code is stored which controls everything. From here you can call on the net, do any calculations, output through windows commands etc.

It is possible to embed script from real languages within this text file which is really handy so within this one file I can call upon C, Java etc which enables me to have a Web style control screen with an easy interface, access to the windows functions and other things.

:wink:

Solved it. Thanks for your help - it indirectly gave me the direction I needed for the solution :wink:

So I can call on the computer port from C so why not do that then embed in the text file which is XML. Windows now recognises the word or phrase, directs to the main XML file then runs an embedded script. What's nice here is its amazingly responsive. What's even nicer is I have one file, one document that runs everything and is easily editable - love it.

Thanks for all your comments - appreciate your help. :wink:

Graeme

Graemelawrie:
It is possible to embed script from real languages within this text file which is really handy so within this one file I can call upon C, Java etc which enables me to have a Web style control screen with an easy interface, access to the windows functions and other things.

In that case this Python - Arduino demo may provide a starting point.

One thing you will need to keep in mind is that everytime the PC program opens the serial port the Arduino will reset. You probably don't want that to happen so your PC program should open the serial port at the start of things and keep it open until you are finished with the Arduino.

If that is a problem because of the way your existing program works maybe you could write a Python program that runs continuously and reads the XML file to find new data which it then sends to the Arduino.

Of course you don't have to use Python - use whatever language you are most familiar with.

...R

Thanks Robin. That's really helpful. I'll have a go with Python as the unit now works for one command and then as you say resets - this is still functional but the slight time lag is not ideal.

The timing of your post was perfect :wink:

It's an interesting little project that is throwing up all sorts of unexpected things. I've never used XML in this way before so it's all a bit new territory for me.

Practice makes perfect though eh?

Thanks again,

Graeme