I have this weird problem with serial over USB (UART) on my mbed_scope2 project.
After using getc the next byte send with putc disappears.
I am sending commands from mbed to PC via the serial class over usb,
using putc (but only if writeable).
Sending streams of commands works fine, commands are things like drawline and
the format is something like this "!l10,20,30,40;" for drawing a line on the PC.
so commands start with an exclamation point.
However there are also some commands that can send data back to mbed.
They start with a question mark. So "?Q;" means send back the ID
number of the last event (like if keyboard was pressed or click on button).
So after sending the "?Q;" command with putc commands (if writeable)
i wait for the response with readable and getc, which works fine too.
However ...
If i after that write the next command to the PC, the first character
(the exclamation point) disappears. So the PC doesn't recognizes
the next command.
So i found a fix by just sending a "space" to PC by using putc
(if writable) after i have used getc.
If i do that the next command is recognized fine by the PC.
But the space send disappears.
As everything which is not a command is printed on the screen, you
would expect the space on the screen. Also if the exclamation
point disappears from the stream the rest of the command which
could not be interpreted is printed on the screen.
I thought maybe its a problem in my PC software, but i don't
seem to have the same probem with javelin stamps
using the same code/protocol.
I have this weird problem with serial over USB (UART) on my mbed_scope2 project. After using getc the next byte send with putc disappears.
I am sending commands from mbed to PC via the serial class over usb, using putc (but only if writeable).
Sending streams of commands works fine, commands are things like drawline and the format is something like this "!l10,20,30,40;" for drawing a line on the PC. so commands start with an exclamation point.
However there are also some commands that can send data back to mbed. They start with a question mark. So "?Q;" means send back the ID number of the last event (like if keyboard was pressed or click on button).
So after sending the "?Q;" command with putc commands (if writeable) i wait for the response with readable and getc, which works fine too.
However ...
If i after that write the next command to the PC, the first character (the exclamation point) disappears. So the PC doesn't recognizes the next command.
So i found a fix by just sending a "space" to PC by using putc (if writable) after i have used getc. If i do that the next command is recognized fine by the PC.
But the space send disappears. As everything which is not a command is printed on the screen, you would expect the space on the screen. Also if the exclamation point disappears from the stream the rest of the command which could not be interpreted is printed on the screen.
I thought maybe its a problem in my PC software, but i don't seem to have the same probem with javelin stamps using the same code/protocol.