Set stty parameters
Asked Answered
O

1

6

Im trying to use bash to read from ttyS0 and need to set the following but im struggling to figure it out

databits = 7
stopbits = 2
parity = 0
flow control = 0

heres my code:

#!/bin/bash

# Port setting
stty -F /dev/ttyS0 raw speed 1200

# Loop
while [ 1 ]; 
do
    echo 'LOADING...'
    READ=`dd if=/dev/ttyS0 count=1`
    echo $READ


echo '[PRESS Ctrl + C TO EXIT]'
done

The script is working but I need to set the parameters. Any suggestions? And thanks:)

Outpour answered 1/2, 2012 at 8:24 Comment(0)
M
9

try

stty -F /dev/ttyS0 cs7 cstopb -ixon raw speed 1200
Molech answered 1/2, 2012 at 15:9 Comment(5)
Allow me to disagree, man stty is a terrible reference, things that matter buried between tons of insignificant junk that might have mattered 50 years ago, and essential entries referenced elsewhere defined in non-searchable way (there's no entry for cs8, just csN). Sending people to man stty is just as bad as sending people wanting to unpack archive to man tar was until recently (with its tape sizes, tape-changing etc)Bounded
@Bounded what resources would you recommend (sorry to ask that nearly 7 years later...)Tierratiersten
@TomS. Asking on StackOverflow. :-/Bounded
@Bounded well you could have answered here as well in the comments, or at least show a stackexchange relevant answer... saying a tool is not working (when in fact still does) and not providing reference to a replacement it not helpful at all! and yes, if you want to unpack a tar file you would still have to read the tar manual page in 2021... and tapes are still the most long life storage choiceSpellbinder
@CostinGușă The answer provided here is correct for the stated problem. If I knew a better source or explanation, I'd surely post it. The answer before edit contained man stty is a good reference. which was the part I disagreed with.Bounded

© 2022 - 2024 — McMap. All rights reserved.