I try port reading and displaying in widgets.Well, I try to demostrate the problem during the next simplified example:
- 1. use Win32::SerialPort 0.09;
-
2. use Tk;
-
3.
-
4. $mw=MainWindow->new();
-
5.
-
6. $mw->maxsize(600,470);
-
7. $mw->minsize(600,470);
-
8.
-
9. ########################### widgets #######################x
-
10. $d1=0.000;
-
11. $e1=$mw->Entry(-width => 10,
-
12. -textvariable => \$d1); #here iwant display the data from port
-
13. $e1->place(-x =>100, -y =>100);
-
14.
-
15.
-
16. $g2 = $mw->Button(-text => "Start read",
-
17. -command => sub{ &read} #here i start the first read
-
18. );
-
19. $g2->place(-x => 240, -y => 100);
-
20. ######################### Port Object#########################
-
21. unless ($soros_port = Win32::SerialPort->new ('com1')) {
-
22. printf "Nem tudtam megnyitni a soros portot!\n";
-
23. exit 1;
-
24.
-
25. $soros_port->baudrate(9600) || die "rossz BAUD";
-
26. $soros_port->parity('even') || die "rossz Parias";
-
27. $soros_port->databits(8) || die "rossz Adatbit";
-
28. $soros_port->stopbits(1) || die "rossz Stopbit";
-
29. $soros_port->buffers(4096,4096) || die "rossz Buffer";
-
30. $soros_port->handshake("none") || die "rossz Handshake";
-
31. ################################################## ########
-
32. MainLoop();
-
33.
-
34. sub read #the function go back whit the data freshing the $e1 widgets
-
35. {
-
36. while(1)
-
37. {
-
38. ($count_in, $d1) = $soros_port->read(1) or die "itten";
-
39. if($count_in!=0) {last;}
-
40. }
-
41. }
-
42. ################################################## #########
-
How can after the return of " sub read" (so refreshing the widget)
fast and automatically call the "sub read" again and again?->so can I continous displaying the data from port (the repeat are to slow->1ms)