The following code use the TCP interface of the daemon
use IO::Socket; printf("========================================================\n"); printf(" Very Simple Perl Test\n"); printf("========================================================\n"); my $sock = new IO::Socket::INET ( PeerAddr => 'localhost', PeerPort => '9598', Proto => 'tcp', ); die "Could not create socket: $!\n" unless $sock; recv( $sock, $buffer, 200, 0); print $buffer; print $sock "user admin\n"; recv( $sock, $buffer, 200, 0); print $buffer; print $sock "pass secret\n"; recv( $sock, $buffer, 200, 0); print $buffer; # # Send a full GUID event # ====================== # Format is # "send head,class,type,obid,timestamp,GUID,data1,data2,data3...." # # Class=20 CLASS1.INFORMATION # TYPE = 3 ON # obid = 0 # timestamp = 0 # GUID = 0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15 on the form MSB->LSB # Zone=1 # SubZone=80 # print $sock "SEND 0,20,3,0,0,0:1:2:3:4:5:6:7:8:9:10:11:12:13:14:15,0,1,80\n"; recv( $sock, $buffer, 200, 0); print $buffer; # # The same thing can be sent using # # SEND 0,20,3,0,0,-,0,1,80 # # where the interface GUID is used. print $sock "SEND 0,20,3,0,0,-,0,1,80\n"; recv( $sock, $buffer, 200, 0); print $buffer; close($sock);
No command verification is done in this sample. Obviously this should be added. Just look for a '+' in the respons for an OK return value.
Discussion