I'm wanting to use a Arduino Mega as a generic IO platform for a commercial (and proprietary) control system. It is particularly useful because of it's 3 UARTs. The general idea is that the control system will connect to the Mega via I2C and be able to use all of the Mega's IO.
I've come up with a basic protocol for the control system to use to talk to the Mega. It's pretty straight-forward and things were going smoothly until I got to the serial ports. I want the control system to be able to send ascii text strings with escape codes in them. Ex:
\x02Some Command\x03
The arduino would take that as a byte array or char array and replace the escape codes with the actual numeric code. From the example above, cmd[0] = 2 and cmd[13] = 3. (Corrected!)
It's not important to me that the escape codes are formatted in a particular way. In other words, the code could be \x02 or \02 or $02. I might slightly prefer generic C type codes.
Are there any built in functions that could make this easier for me or do I just have to bite the bullet and write it myself?
el_supremo, I do need to be able to send null bytes.
Robin2, Since I don't know what equipment the arduino will be connected to, I can't mandate a specific protocol. The system does need to receive data as well.
The equipment I control DO NOT translate escape codes. So I can't just pass them, I have to convert them to the actual thing before passing the control string.
I thought that, since C strings automatically convert escape codes from string literals that there might be some mechanism there that I could take advantage of.