Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

TCL routines for RS232 communication

Status
Not open for further replies.

kukurigu

Junior Member level 3
Joined
Dec 14, 2002
Messages
25
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,283
Activity points
272
Hello all!

I'm looking for TCL routines for RS232 communication - receive, transmit, baud rate selection ...

Can you help me?
Best Regards!
 

psubiaco

Member level 2
Joined
Apr 6, 2003
Messages
42
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Location
Italy
Activity points
610
Using RS232 serial port with TCL scripting language is very very easy.
Consider that the OS will buffer serial port too, so the device which transmit data to the PC serial port must supply a carriage return '\n' at the end of frame.
The routines below will work with both windows and linux OSes.
Regards. Paolo

Code:
if [string equal -nocase $tcl_platform(platform) {windows}] {
  set comport com1
} else {
  set comport /dev/ttyS0
}

if { [catch {open $comport {r+}} fdin] } {
  puts stderr "Error opening serial port $comport"
  after 2000
  exit
}
fconfigure $fdin -mode 38400,n,8,1 -blocking 0 -translation binary -buffering none
 

zmanultra

Member level 2
Joined
Mar 20, 2004
Messages
48
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Location
Australia
Activity points
524
psubiaco said:
Using RS232 serial port with TCL scripting language is very very easy.
Consider that the OS will buffer serial port too, so the device which transmit data to the PC serial port must supply a carriage return '\n' at the end of frame.
The routines below will work with both windows and linux OSes.
Regards. Paolo

Code:
if [string equal -nocase $tcl_platform(platform) {windows}] {
  set comport com1
} else {
  set comport /dev/ttyS0
}

if { [catch {open $comport {r+}} fdin] } {
  puts stderr "Error opening serial port $comport"
  after 2000
  exit
}
fconfigure $fdin -mode 38400,n,8,1 -blocking 0 -translation binary -buffering none


i see what you have done ..but can u show me how to do this in window..cause i think its abit diffrernt isn't it.
 

sinatra

Full Member level 4
Joined
Mar 29, 2002
Messages
214
Helped
18
Reputation
36
Reaction score
7
Trophy points
1,298
Location
Neverland
Activity points
2,842
Hello all.
If I'm not wrong the RS232 full control is already avilable in the latestest releases if TCL, for example 8.4.
Just try google "tcl/tk" serial port.....
You will find a lot.
S.
 

zmanultra

Member level 2
Joined
Mar 20, 2004
Messages
48
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Location
Australia
Activity points
524
:D
i get an this error when i try to open com 1 or com 2

all i wrote is this -> set serial [open com1 r+]
and i get this error -> permission denied

iv got windows xp

i dont get it :x
 

dynoboy

Junior Member level 2
Joined
May 28, 2004
Messages
24
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
India
Activity points
315
Oh so trying to access hardware via WinXP...no !! thats not a very convenient thing to do..as the OS does not allow such things ...you will have to incorporate some additional code...
 

zmanultra

Member level 2
Joined
Mar 20, 2004
Messages
48
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Location
Australia
Activity points
524
dont worry bro, iv fixed it, i dont think you have to add extra code, r u sure you know what your talking about, cause iv fixed the problem and its really simple as.
and actully its no extra code that was required. just used my head a little, but thanks for trying to help. :D
 

PredAlien

Newbie level 6
Joined
Sep 8, 2004
Messages
14
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
180
im having the same problem about accessing the com port using tcl, i beg u to tell me how u did it, please, im dying here :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry: :cry:
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top