Tcl: How to communicate serial port remotely


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Tcl: How to communicate serial port remotely
# 1  
Old 10-26-2010
Tcl: How to communicate serial port remotely

Hi all:

i wanna automate a test written in Tcl, but stuck in serial communication.

I had 2 PC, one is my local Windows machine, the other one is my test Linux server. The Linux box is connected to the test board via serial port. So I wanna send commands and get output through the serial port.

So i wrote a Tcl script, and wanna call the scripts in Windows, remotely connect to the Linux server and talk to the test device via serial port. It failed so far. I used 'Open' in tcl to create a serial connection in Linux.

Code:
 ex. set fh [open /dev/ttyS0 RDWR] 

what I learn the reasons why this may not work are that (in my option):

first, fh is a file descriptor if one open a file (in linux, all devices represent a file), so u cant monitor a live test, instead read a file line by line after a numbers of seconds. I doubt there is no eof in /dev/ttyS0, which means even u can read from it, if no incoming output, u can still read an empty string without issuing an error.

second, since i remotely connect to linux box from window pc, tcl interpreter is confused by which serial port i was trying to open, (windows? or Linux? I am using a virtual Linux in Windows to call the script, connect to the Linux sever, trying to communicate the device connected to there.)

I hope everyone understand my situation, and my purposes now.

I really appreciate all your suggestion regarding how to remotely commnucate serial port in Tcl.
# 2  
Old 10-26-2010
Unfortunately I don't know TCL well but I have other suggestions... First off make sure that the port is set to the correct baud rate and mode.
Code:
stty -F /dev/ttyS0 9600 CS8 -cstopb -parenb raw

should set it to 9600-baud, 8-bit, one stop bit, no parity, raw mode(i.e, ctrl-c doesn't send SIGINT!). This doesn't have to be run inside your program, and it ought to remember once run once unless something else changes it(or your system reboots).
# 3  
Old 10-26-2010
Quote:
Originally Posted by Corona688
Unfortunately I don't know TCL well but I have other suggestions... First off make sure that the port is set to the correct baud rate and mode.
Code:
stty -F /dev/ttyS0 9600 CS8 -cstopb -parenb raw

should set it to 9600-baud, 8-bit, one stop bit, no parity, raw mode(i.e, ctrl-c doesn't send SIGINT!). This doesn't have to be run inside your program, and it ought to remember once run once unless something else changes it(or your system reboots).
Thanks!

I had done both stty configuration and double check with minicom -s

The settings is correct, but what I am interested in is which serial port is going to open, on windows or linux, as there is no specific option in Open command in tcl.
Thus, I doubt the Tcl Open my windows serial port (since i had virtual linux, all ttys are mounted to com) rather than the one in my Linux server.
# 4  
Old 10-29-2010
Quote:
Originally Posted by allenxiao7
Thus, I doubt the Tcl Open my windows serial port (since i had virtual linux, all ttys are mounted to com) rather than the one in my Linux server.
I think Windows still has special names for devices lurking around in a DOS-like manner. You might, just might, be able to get away with opening COM9 or something.
# 5  
Old 10-29-2010
No solution to offer, but if anybody wants to read about Tcl :
Language
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Cabling and adapters to communicate to service processor serial port from Windows PC with USB port.

Hello, I have an unloaded T5140 machine and want to access the ILOM for the first time and subsequently the network port after that., and then load Solaris 10 the final January 2011 build. The first part is what confuses me -the cabling. I am coming from a Windows machine (w/appropriate... (5 Replies)
Discussion started by: joboy
5 Replies

2. Web Development

Setup Serial Port

I need to set a serial port to 9600 7E1. How do I accomplish this? I've tried every combination, with no luck. (6 Replies)
Discussion started by: Meow613
6 Replies

3. Solaris

Using PC serial port from ReflectionX

I am using ReflectionX on a windows PC to run an application on a Solaris box. The application uses the serial port and expects a definition like: /dev/ttyb Is there a way to use the PC serial port through ReflectionX? PC is running Windows-XP Solaris Box is: Sun Microsystems sun4u... (1 Reply)
Discussion started by: deanjennings
1 Replies

4. Solaris

How to enable Serial port on ILOM, when Network Port is enabled in parallel

Hi Everyone, In my environment, I have few T5220. On the iLOM Management Card, I have both Network and Serial port are cabled, I don't have any issues while I try to connect using Network Management port, but when I try to connect the serial port for the same server which is actually connected... (3 Replies)
Discussion started by: bobby320
3 Replies

5. Shell Programming and Scripting

Need help with serial port

Hi, I have a external board connected to my serial port. I need to execute "shutdown -r now" command when system boot up. When system boots up it requires a username ans password. Then I need to run my command. I can use rc script but that is rebooting system before it asks for username and... (0 Replies)
Discussion started by: charlie.arya
0 Replies

6. Programming

How to tell if a string to serial port has been sent

I have a need to determine when a string has been completely sent via a serial port from a standard 'C' application. The code is as follows: SerialPort_Send = open (pPortString, O_WRONLY | O_NOCTTY | O_NONBLOCK); write (SerialPort_Send, pCommandString, strlen (pCommandString)); ... (2 Replies)
Discussion started by: ExDes
2 Replies

7. Programming

Programming serial port

Hello! Can someone advice me which method I will use if I want to communicate with device via RS232 serial port with this requirements: 1. Serial port is opened in non-canonical mode. 2. All the time I need to check is there something to read. 3. If I have to write something I need to write it... (6 Replies)
Discussion started by: jvrlic
6 Replies

8. Solaris

Serial port not found

Hi, I am working with solaris 9,SUN-Blade-100 and I want to communicate with the Serial port.To check whether the port is working or not.I write code and when I execute the file,then I got the output-- According to this,serial port is not found.can anyone please tell me how to configure the... (1 Reply)
Discussion started by: smartgupta
1 Replies

9. Solaris

Serial port issue

Hi, I am working with Sun Solaris 9 Sparc,Sun-Blade-100.In my application,I need to monitor the UPS using Serial port. When I am using JRE 1.4 in my application,I am able to monitor it but when I am upgrading the JRE version from 1.4 to JRE1.6. I am not able to monitor the UPS.It is showing the... (1 Reply)
Discussion started by: smartgupta
1 Replies

10. Solaris

Communicate Serial Modem using non-Root user

Hi, I'm having a issue on communicating the serial GSM modem in Sun Solaris 5.9 To implement such connectiom, i'm using the "tip -115200 /dev/term/a" command and i successfully get the "connected" status And then i send a "AT" message and receive "OK" response from the modem :D Anyhow,... (0 Replies)
Discussion started by: darontan
0 Replies
Login or Register to Ask a Question