LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-24-2007, 09:58 AM   #1
kafix
LQ Newbie
 
Registered: Jul 2007
Posts: 3

Rep: Reputation: 0
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:
  • Transmit a break time, which is a logical "0" lasting for 88 microseconds. On a microcontroller you can usually do this by temporarily setting the baud rate to 96KBaud, then transmit a "0" byte.
  • Then transmit a startcode of "0" (returning the baud rate to 250KBaud).
  • Then transmit up to 512 8-bit channel level bytes
Source: sabretechnology.co.uk/dmxwork.htm
Now I'm not quite sure how to implement that. My version:

Code:
stty -F /dev/ttyS0 96000
echo 0 > /dev/ttyS0
stty -F /dev/ttyS0 250000
echo  0ggg > /dev/ttyS0
Now, that doesn't work. (The device's data-LED is on when I run the script.) With stty I couldn't set the baud-rates to the 96k and 250k as written in the specifications (Error message: stty: invalid argument ,,96000"). BTW: Changing to 9600 and others does work!

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?

Last edited by kafix; 07-24-2007 at 07:06 PM.
 
Old 07-24-2007, 12:00 PM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
 
Old 07-24-2007, 12:24 PM   #3
kafix
LQ Newbie
 
Registered: Jul 2007
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 07-24-2007, 07:07 PM   #4
kafix
LQ Newbie
 
Registered: Jul 2007
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 07-24-2007, 07:21 PM   #5
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
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.
 
Old 07-25-2007, 01:11 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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).
 
Old 07-25-2007, 06:32 PM   #7
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
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.
 
Old 07-25-2007, 11:31 PM   #8
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
 
Old 07-26-2007, 05:54 PM   #9
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
Quote:
Originally Posted by Wim Sturkenboom
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.
Ahh, I get it ...
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).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
SF Thinstation redirected com port baud rate JoDee Linux - Software 0 09-11-2006 01:25 PM
Need help setting serial port baud rate to 4800. mathew1468 Linux - Hardware 2 07-14-2006 04:06 PM
usb to serial converter non standard baud rate scgs Linux - Kernel 3 06-14-2006 12:16 AM
Reading Baud Rate of Serial Port zaheer031 Programming 1 09-27-2004 01:47 PM
How do I change ttyS port baud rate? joe_dejesus Linux - General 1 09-27-2001 10:50 PM


All times are GMT -5. The time now is 10:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration