Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

problem with fileevent

problem with fileevent

problem with fileevent

I want to save 6 variables incoming over a serial port. These variables are transmitted one after another in one line. This line is sent repeatedly every second in order to update the variables.
The code works correctly, but only for the first line. Afterwards I get the message "invalid command name "ChME3"", where "ChME3" is the first variable in the line.
What's wrong with my code?

CODE -->

set data {}
	set LIST {}
	set var0 {}
	set var1 {}
	set var2 {}
	set var3 {}
	set var4 {}
	set var5 {}

	set chan [open com5 r]
	fconfigure $chan -mode "9600,n,8,1" -blocking 1 -buffering none -translation binary
	fileevent $chan readable [set data [gets $chan]]

	set LIST [concat {*}[split $data]]  ;
	lassign $LIST var0 var1 var2 var3 var4 var5
	puts "data:  $data"
	puts "LIST:  $LIST"
	puts "var0:  $var0"
	puts "var1:  $var1"
	puts "var2:  $var2"
	puts "var3:  $var3"
	puts "var4:  $var4"
	puts "var5:  $var5" 

RE: problem with fileevent

Is that all the code or is there some more? I can't see how it does subsequent reads.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close