We issue the command ‘Q’ but there is no answer back by the serial port. However, when we issue “SS” or “VER” commands then the answer from “Q” command does appear for instance “.” and afterwards the start up string or the firmware version. It is like the answer was stored in the registers instead was transmitted through the serial port. Any suggestion??
Again it would be good to have additional information. Like what platform is this on? Which version of C are you using. How does your read work? Are there timeouts? If so what is it set for? Some implementations may be such that it does not return the data until it receives a complete line of text, which is why the command “VER” would work fine as it returns a complete line of text.
The program is running under Linux Debian 5 and the it is designed in ANSI C and compiled with a gcc version 4.3.2. As you can see in the read function there isn’t any timeout. When we issue a ‘Q’ or even an ‘A’ command the result from the read method is -1 so it 's like it wasn’t any reading, however it goes fine with “VER”,“SS” commands retrieving the at the same time the answer from Q and A, previous commands. Do you know what’s going on?
Sorry, but I am not a Linux expert. I am suspecting that the Linux serial port driver buffers data up and only passes it up when it receives something like a CR or potentially some timeout. I would look at what options I had when I opened the logical file associated with the port…
Also I would look into timings of your program. That is if you quickly issue the “Q” and then do the read. It could be possible that the data has not had enough time to propagate up to the buffer… You might try putting a slightly delay in and see if it does come through.