Author Topic: Print to ttyS0  (Read 9669 times)

Ken Arck

  • Guest
Print to ttyS0
« on: January 22, 2012, 04:08:10 PM »
Obviously this in Linux

I have an external hardware device that requires the following sent to it via RS232:

1*21999<CR>

So in Scriba, my line is (after opening Open /dev/ttyS0 For Output as #2)

Print #2, "1*21999\n"

But it doesn't seem to send Chr(13) correctly (Chr(13) is CR, right?)

If I send 1*21999 via minicom, it works properly but if sent from Scriba, the external device ignores it.

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Print to ttyS0
« Reply #1 on: January 22, 2012, 05:33:50 PM »
Try "1*21999\r\n"

\r = RETURN
\n = LINEFEED

Ken Arck

  • Guest
Re: Print to ttyS0
« Reply #2 on: January 22, 2012, 05:57:09 PM »
Nope, didn't fix it.

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Print to ttyS0
« Reply #3 on: January 22, 2012, 06:14:42 PM »
ScriptBasic assumes that the tty port is setup correctly at the Linux level.

When you say it isn't working, are you seeing anything or just not doing line termination correctly?

If your device is only looking for a CHR(13) (RETURN) for a line terminator then just use \r only.

Ken Arck

  • Guest
Re: Print to ttyS0
« Reply #4 on: January 22, 2012, 06:22:39 PM »
I probably need to look at the data stream because I can echo from the bash prompt (echo 1*21999 > /dev/ttyS0 and that works fine. Between that and minicom, it shows the port is configured ok under Linux itself. I have looked at the output on another computer running a term prog and it *looks* ok but obviously it isn't.

It's just from within Scriba that it doesn't work.

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Print to ttyS0
« Reply #5 on: January 22, 2012, 06:25:58 PM »
Please post the relevant code you are using to communicate with the serial port.

I haven't tried using SB with a serial port before but I see no reason it shouldn't work.

This works even though it isn't a tty serial port in the true sense.

Code: [Select]
OPEN "/dev/tty" FOR OUTPUT AS 1

PRINT #1,"Test\n"
LINE INPUT #1, i
PRINT i

jrs@laptop:~/sb/test$ scriba ttytest.sb
Test
jrs@laptop:~/sb/test$

« Last Edit: January 22, 2012, 06:40:27 PM by support »

Ken Arck

  • Guest
Re: Print to ttyS0
« Reply #6 on: January 24, 2012, 04:25:07 PM »
Thanks for the info guys. I was able to make it work -it turns out it was a problem caused by changing baud rates which caused ttyS0 to send extraneous characters ( I was changing baud from 57600 to 9600, sent my string and then reset the baud to 57600.

Now I have another problem but I'll start a new thread about that as it is installation related on a different Linux computer