Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cant open serial port with [open /dev/ttyS0 r+]

Status
Not open for further replies.

Arepi

Technical User
Oct 23, 2008
17
0
0
HU
Hi,

When I try to open a serial port like this:
Code:
set serial [open /dev/ttyS0 r+]
I get: " couldn't open "/dev/ttyS0": no such file or directory"

When I use this form:
Code:
set serial [open COM1: r+]
It works properly.

It might be importent to know why is it as i would like open USB connection like
Code:
/dev/ttyUSB0

I use Windows XP and Active Tcl 8.5.8.2.

Thanks

Arepi


 
In Linux, everything is a file. The /dev directory is part of Linux OS architecture containing special device files that allow for user applications to interface with hardware.

This mechanism of communicating with devices does not exist on MS Windows which you are trying to do. I have used Windows API such as DeviceIOControl to communicate with devices. TCL may provide higher level abstraction to communicate with devices such as 'open' command (which I see you are using) but I haven't used it.

Hope this helps.
 
Thanks for answer

My first mistake i tried this expression under Win.
Anyway open a port with simple 'open' works in Tcl even under windows, I tried and worked fine.
Otherwise /dev/ttyUSB0 could be works only under linux so im sorry, i asked a really irrelevant question.
Anyway at last I tried under UNIX and still not works.

Thanks again

Arepi
 
Thanks, but as I see all of them about serial port handlig. As I mentioned COM handling works me properly. I would like handle an USB port either under UNIX or Win.

Anyway thanks

Arepi
 
Primilinary search indicates to me that TCL maynot be sufficient to open usb port. You may have to look into writing C/C++ code to accmplish that.

For Unix, you have to use open, read, close etc. file functions to read usb port. For example, under Unix you can run command "man 2 read" to learn about read function.

For Windows, you can use DeviceIoControl. You can visit MSDN for more information.

First ensure C/C++ code can do what you want it to do. Then call compiled code from TCL program using exec command.
For example,
Code:
puts "Calling C/C++ Usb read program..."
set status [catch {exec /path/to/exe/usbread_app.exe} result]
puts "$result"
if {$status} { puts "usbread_app error: $status}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top