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!

problem with fileevent

Status
Not open for further replies.

Hans.

Technical User
Apr 30, 2019
1
CH
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"

 
Is that all the code or is there some more? I can't see how it does subsequent reads.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top