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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial communication on win98

Status
Not open for further replies.

oakleaves

Technical User
Jul 25, 2001
1
0
0
CN
I want to simulate hyperterminal by TCL/TK programming.And I connected com3 to Console of my router via console cable.But I met some problems.I used a package named tcl-dp. I used "dp_connect -device com3" command to open Serial3,and used fconfigure -charsize 8,-bits 1,-baudrate 9600,stop "none"" command to configure
the serial, and used "dp_send $com3 string" to send commands to the router, and used "dp_recv $com3" to receive the results which the router displayed.Here's source codes:

lappend auto_path .
package require dp 4.0

catch {console show}

##### main #######

puts "This is a test!"

set com3 [dp_connect serial -device serial3]

fconfigure $com3 -charsize 8 -stopbits 1 -baudrate 9600 -parity "none"

dp_send $com3 "show run"

after 500

puts [dp_recv $com3]

But I got wrong results. The router could execute commands correctly that I send to it but could not echo the results on my console. But when I opened hyperterminal and keystroked Enter, I found the results was displayed on the
console. I have struggled for it for 1 month, but gotten nothing. I have to ask for your help, because I think my boss is killing me if I have no answer in time. By the way, My platform is win95/NT.
 
I have answered this question before, but will do it again here, without doing a FAQ. If you are connecting to any server via the IO mechanism and expect the server to reply to the 'puts whatever' line you just invoked, you MUST use the flush command to flush the output buffer to the channel. If you don't, the output channel will wait until the output buffer (usual default 4k in size) is full. I am not familiar with the package you are using, but let's hope it is using the core buffering mechanism. Good luck with your boss...

Mike Suttles
Xerox OPBU Technology Development Group

 
I'm in the same spot. Did you find a solution to your problem?
Thanks,
Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top