serial1.read() behaving like serial.peek()

Hello,

I was hooking up a serial camera to the spark core last night.
After hours of testing we ended up throwing out the library that was part of the tutorial for the device because it was clearly not working.

So we decided to just use the serial1 library and re write everything from the ground up. Here is our test.

Bare bones test for serial communication:


Serial1.begin(38400);
delay(10);

uint8_t x;
uint8_t y;
uint8_t z;
uint8_t a;

Serial1.write(0x56);
Serial1.write(0);
Serial1.write(0x11);
Serial1.write(0);

x = Serial1.read();
y = Serial1.read();
z = Serial1.read();
a = Serial1.read();

Output from above test script.


Results failed: Sent 0x56 0 0x11 0 Response 0x76

Expected results: 0x76 0 0x11 0 ‘data’

We started testing with just variable X. It was being set to 118 = 0x76 in hex. So this was encouraging because we got a response back from the device. No matter what we tried we could not get any more data. Just a Received response. We added multiple serial1.read() set to different variables y, z, a and all the variables get set to 118 .

Conclusion:

Serial1.read() does not iterate to the next byte of data in the buffer. It seems to be acting like Serial1.peek() that just views the data in the buffer but does not remove it to.

**

  • Help, Thoughts or explanations would be greatly appreciated.

**


1.2.Communication Protocol

Communication Protocol format are as follows:

Receive command format:
Protocol sign(1byte)+Serial number(1byte)+Command(1byte)+Data-lengths(1byte)+Data(0~16bytes)

Return command format:
Protocol sign(1byte)+Serial number(1byte)+Command(1byte)+Status(1byte)+Data-lengths(1byte)+Data(0~16bytes)

Protocol sign:
it marks that the protocol is VC0706 Serial Communication Protocol, the receive
sign is0x56(‘V’), return sign is 0x76(‘v’).

Command sent:
GEN_VERSION 0x11 Get Firmware version information

Serial communication datasheet.

Data Sheet

Hi Brian,

Were you building code using the build IDE, or were you building locally from a local environment? I know our firmware guys have added a ring buffer for the serial object, but we haven’t rolled it out into the stable build ide branch yet. I wonder if those changes would fix the issues you’re seeing? The hope is to have these updates released in the next few days when they’ve passed QA.

Thanks,
David

I’m very waiting for Serial1 pathches come to Web IDE :slight_smile: Currently it is a roadblocker for continuing testing required functions for projects.

We completed all steps to install the firmware locally.Also we had to clean up our test code to work locally. The same code in the Web ide does not directly work with the local firmware install.

Sad to say we lost communications with the serial device when installing the firmware locally. Most recent firmware was pulled from github.

Gave up for now. Didnt want to debug low level serial communication issues.