Serial port: write single bit (Updated)
(See update below)
Hi! I'm trying to get a serial device working on my linux (debian) system. On the internet, I found these rules for the communication: Quote:
Code:
stty -F /dev/ttyS0 96000 How would you implement these specifications? Could anybody help me, please? kafi (Sorry for my english) UPDATE 07-24-07 06:02 PM Ok I think I could fix the baud-problems on my own. But now I should write single bits to the serial port. Is this possible using bash? |
I assume that the following is (one of) your problem(s):
The 0 that you tranmit is the character 0 (30h) and not 00h. You can try \x00 instead of 0, but I'm not that familiar with bash scripting to give you a garantee about the correctness. |
Thanks for your reply! I don't see any changes yet, but I agree that your \x00 is likely to be more correct that just 0. Thanks for your hint!
kafi |
Ok I think I could fix the baud-problems on my own. But now I should write single bits to the serial port. Is this possible using bash?
cu kafi |
In terms of RS232 serial communications ...
a logical 0 is a positive voltage state a logical 1 is a negative voltage state By sending any data through the serial UART you are creating voltage transitions that reflect the data bits being sent. It sounds like you are trying to induce a serial break. A serial break signal is a logical 0 (positive voltage) for longer than a character length. |
What do you mean by 'write single bits'? The uart will always output a specified number of bits. Usually it's 7 or 8, but 5 is possible as well (if I remember correctly it's the lowest that I have seen).
|
You cannot create a hardware break by sending data.
The break (logical 0) must span longer than a character length. Example ... minicom can perform such an action. How you do this in a shell script ?? I do not think the shell has ability to do this. Other programing languages have a serial library that can do this such as C ... or possibly perl. |
As described in opening post, I think one can by changing the baudrate to a lower value and transmitting the 'break'. The receiving end will not change the baudrate, so it will see a longer logical 0.
|
Quote:
Open the TTY, then drop the /dev/ttyS0 speed lower than the serial devices speed ... then send a null (\x00) ... and the output character will be logical 0 and the lower baud rate will make it appear to the serial device as being longer than it's expected character length (then flip the/dev/ttyS0 back to normal speed). |
All times are GMT -5. The time now is 11:17 AM. |