PC to Arduino: Serial BOF and EOF control codes

(First of all, I’ve tried to train myself to refer to the data sent over the serial port as ‘command codes’ but I always find myself lapsing into calling them ‘control codes.’ So I give up for today.)

Here’s what I send from processing:

          int outgoingbyte = 125;
          for (int i = 1; i<=cnum; i++){
          outgoingbyte = 126;

And here’s how the Arduino receives it:

	if (Serial.available() < 1) {

	incomingByte = Serial.read();
        if (incomingByte == 125){
          cc_count = 0;
        if (incomingByte == 126) {
        cc_count = cc_count + 1;
        cc_list[cc_count] = incomingByte;

As you can see, I commented out most of the code here because it wasn’t working and I needed to test it. What the uncommented code does is turn on the pin 13 LED to confirm when serial data is received. And yes, the LED went ON, so I know that data is coming over.

Originally, however, the code was written to turn on the pin 13 LED when a value of 125 (= BOF = Beginning Of File) is received and turn off the pin 13 LED when a value of 126 (= EOF = End of File) is received. It wasn’t doing that.

So where am I? I know that data is going over the serial port, but apparently it’s not being read the same way it was written. Now I need to find out why, or find a way to work around the problem.

About engineerzero

Once and future engineer.
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s