Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#85017 - 02/04/2002 20:00 canot connect thru the serial port under liunux
GlarySandstorm
new poster

Registered: 29/03/2002
Posts: 3
I've just recently solved a serial port problem under linux that took me several days to figure out so I thought I would post the solution here so that it might help someone else. canuckInLA actually gave me this solution thanks again to hime.

My problem was that I could not conect to the player (a rio car mark 2) under linux using the serial port. My computer dual boots linux and NT and I fould that I could connect under NT with no problem. Under linux I found that I could connect with upgclient and with minicom with no problems.

Obviously upgclient and minicom knew how to set the port right; so the problem became - how to figure out what settings minicom was using.

I.E. with minicom its pretty easy to set 115200 baud, 8 data bits, no parity, 1 stop bit and no flow control (those are the settings the empeg units needs) - those entry are in minicom's setup almost exactly as I just showed them.

But the command a user must use to set the serial port is stty which uses arcane options like -parenb -cstopb -crtscts and whole bunch of others.Which ones are equivelent to 115200, 8, N, 1, no flow control?

The solution is deceptively simple. So simple I was completely over looking it. You connect with minicom, then examine the settings its using with stty.

For those that do not know, stty is a command that is used to set a serial port's characteristics. /dev/ttyS0 is com1, /dev/ttyS1 is com 2.

The first stty command you need is sane.
stty -F /dev/ttyS0 sane
This will set some default "sane" settings

To examine the serial port settings you type one of two commands:
stty -F /dev/ttyS0 (this just shows what different bewtween
the current settings and the sane settings)
stty -F /dev/ttyS0 -a (will all of the current settings)

So, you open two teminals. In one you start mincom and set it to 115200, 8, N, 1, no flow control, then cycle the power on the empeg unit to connect. After its connected, open another terminal and use stty to look at the current settings. The you can build a command to set the same settings (and save it to a script that you can use later)

So, here is the whole process:

(with minicom running and connected in another terminal)
> stty -F /dev/ttyS0
speed 115200 baud; line = 0;
min = 1; time = 5;
ignbrk -brkint -icrnl -imaxbel
-opost -onlcr
-isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

(now close minicom,
then type the following command
built from the output above)

stty -F /dev/ttyS0 sane
stty -F /dev/ttyS0 115200 line 0 min 1 time 5 ignbrk -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

Note that you cannot take the `stty -F /dev/ttyS0` output directly. The syntax used to show the settings and the syntax used to set settings is slightly different.

You may have to do all of that as root, at least the stty commands. It depends on the permisions on you serial port device.

Hope that helps someone else.

Top
#85018 - 02/04/2002 22:13 Re: canot connect thru the serial port under liunux [Re: GlarySandstorm]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I don't understand. You say:
    Under linux I found that I could connect with upgclient and with minicom with no problems.
What was it that wasn't working? emptool, maybe?

Also, the stty options are well documented in the stty man page, but they don't look quite like what you'd expect to see in a terminal application like minicom. Specifically, you'd want something like ``stty -parenb -cstopb cs8 -crtscts -ixon -ixoff 115200 < /dev/ttyS0'', IIRC. (I prefer to redirect stdin rather than use the `-F' option since it varies amongst different OSes, when it exists at all.)
_________________________
Bitt Faulk

Top
#85019 - 02/04/2002 23:38 Re: canot connect thru the serial port under liunu [Re: wfaulk]
GlarySandstorm
new poster

Registered: 29/03/2002
Posts: 3
Sorry, Guess I didn't explain that too well. It was emptool that would not connect thru the serial port. I had to boot to NT in order to change the ip address. Back in linux emptool would connect thru ethernet but not thru serial.

I've never had to configure the serial port characteristics and it took me a while to figure out what to do. I tried lots of different parameters for stty and could not get it right.

Finally someone pointed out that since minicom would connect, I could look at the serial port settings while minimcom was connected and just set the port the same way.

That was how I got emptool to connect thru the serial port. Perhaps I didnt explain that too. Hope it does help someone else though

Top
#85020 - 03/04/2002 10:53 Re: canot connect thru the serial port under liunu [Re: GlarySandstorm]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I understood how you discovered the serial port settings. Pretty clever. Makes a lot of sense. It's just that you didn't mention emptool.
_________________________
Bitt Faulk

Top
#85021 - 04/04/2002 13:30 Re: canot connect thru the serial port under liunux [Re: wfaulk]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
In reply to:

Also, the stty options are well documented in the stty man page,




Maybe your idea of well documented is different than mine. There was copious amounts of documentation, yes. But lets face it -- even with the docs, those command line switches are pretty non-intuitive. I mean... you have both -ixon and -ixoff in the example you gave. Surely it shouldn't be both.

In reply to:

I understood how you discovered the serial port settings. Pretty clever.




Thanks.


Edited by canuckInLA (04/04/2002 13:32)

Top
#85022 - 04/04/2002 14:46 Re: canot connect thru the serial port under liunux [Re: canuckInOR]
djc
enthusiast

Registered: 08/08/2000
Posts: 351
Loc: chicago
I mean... you have both -ixon and -ixoff in the example you gave. Surely it shouldn't be both.

err, yes, it is both. -ixon disables XON/XOFF processing on the input stream, and -ixoff disables the generation of XON/XOFF codes in the TTY driver.

the hyphen before each of the option names means disable, so the opposite of -ixon is simply ixon, not -ixoff.

man stty is your friend.

--dan.

Top
#85023 - 05/04/2002 14:48 Re: canot connect thru the serial port under liunux [Re: djc]
canuckInOR
carpal tunnel

Registered: 13/02/2002
Posts: 3212
Loc: Portland, OR
*sigh* You see? FWIW (which obviously isn't much), I read the man page about 8 times. I think part of my difficulty was the flags that turned out common options. There's a whole lot of "this is the same as this" and "this is the opposite of that" and I soon found myself trying to untangle a plate of mushy spaghetti. :P

Top