Think about Loose Coupling | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Continuation ... SummarySo what the C code does is allow to call getter functions and setter functions (just like getters but without a response) to talk to hardware using a TCP/IP connection. The getters can timeout. You can also register for callbacks to be notified by the hardware without having to poll for it. Finally the IPConnection automatically takes care of reestablishing the TCP/IP connection if it gets lost. The C code does all this by using two threads and sharing a socket between the receive thread the callback thread and the main thread of the program. Obviously this doesn't work 1:1 in Perl due to the different threading model. And I ran into some trouble there already. But the goal is to get the same features in Perl. For comparison here is the current temperature getter example ( https://raw.githubusercontent.com/Tinkerforge/temperature-bricklet/master/software/examples/perl/example_simple.pl ) and the temperature callback example ( https://raw.githubusercontent.com/Tinkerforge/temperature-bricklet/master/software/examples/perl/example_callback.pl ) in Perl. Here's the full C code ( http://download.tinkerforge.com/bindings/c/tinkerforge_c_bindings_2_0_13.zip ) and the current Perl code ( http://download.tinkerforge.com/bindings/perl/tinkerforge_perl_bindings_2_0_1.zip ). Note that I'm currently working one Perl code and that the provided version has a bit of code duplication it it that makes the internal logic a bit hard to follow. Edit: Okay, I cannot use a tags here, contradictory the documentation. I thought the post would have been to long and splitted it into three posts.In reply to Re^2: Socket client thread design problem
by photron
|
|