Currently i am working on a project to send a UDP packet through the ArtNet protocol and receive a message back and read and output it. right now i can send the message fine and the device i send it to responds but i cant read the packet and out put the datagram. My code looks like this: -
#!/usr/bin/perl
-
print "Content-type:text/html\n\n";
-
-
use IO::Socket;
-
#use strict;
-
-
my $ID = 'Art-Net';
-
my $space =' ';
-
my $Prover = chr(0x0e);
-
my $filler = chr(0x00);
-
my $ttm = chr(0x02);
-
my $pad_len_18 = 18;
-
my $pad_len_64 = 64;
-
my $pad_len_34 = 34;
-
-
#---------------ArtPollReply Buffer--------------------------------------------------
-
my $ID = $ID.$filler;
-
my $OpCode = $filler.'!';
-
my $IP = chr(0x02).chr(0x00).chr(0x00).chr(0x02);
-
my $Port = chr(0x36).chr(0x19);
-
my $vers = chr(0x02).chr(0x04);
-
my $subsw = chr(0x00).chr(0x00);
-
my $oem = chr(0x02).chr(0x10);
-
my $UBEA = chr(0x00);
-
my $status = chr(0xd2);
-
my $ESTA = chr(0x4c).chr(0x41);
-
-
my $short_name = 'Test';
-
my $long_name = 'Test Node 1';
-
my $report = 'Node is working.';
-
-
$short_name = $short_name.$filler x ( $pad_len_18 - length( $short_name ) );
-
$short_name = $short_name.$filler x ( $pad_len_18 - length( $short_name ) );
-
-
$long_name = $long_name.$filler x ( $pad_len_64 - length( $long_name ) );
-
$long_name = $long_name.$filler x ( $pad_len_64 - length( $long_name ) );
-
-
$report = $report.$filler x ( $pad_len_64 - length( $report ) );
-
$report = $report.$filler x ( $pad_len_64 - length( $report ) );
-
-
my $numport = chr(0x00).chr(0x08);
-
my $port_type = chr(0xc0).chr(0xc0).chr(0xc0).chr(0xc0);
-
my $imput_status = chr(0x80).chr(0x80).chr(0x80).chr(0x80);
-
my $output_status = chr(0x80).chr(0x80).chr(0x80).chr(0x80);
-
my $imput_switch = chr(0x10).chr(0x11).chr(0x12).chr(0x13);
-
my $output_switch = chr(0x00).chr(0x01).chr(0x02).chr(0x03);
-
my $swvideo = chr(0x00);
-
my $swmacro = chr(0x55);
-
my $swremote = chr(0xaa);
-
my $spare = chr(0x00).chr(0x00).chr(0x00).chr(0x00);
-
my $MAC = chr(0x00).chr(0x00).chr(0x00).chr(0x00).chr(0x00);
-
#----------------------------------------------------------------------------------
-
-
#-------ArtPoll-------
-
my $ArtPoll = $ID.$filler.$space.$filler.$Prover.$ttm.$filler;
-
#-------ArtPollReply----
-
my $ArtPollReply = $ID.$filler.'!'.$IP.$Port.$vers.$subsw.$oem.$UBEA.
-
$status.$ESTA.$short_name.$long_name.$report.$numport.$port_type.$imput_status.$output_status.
-
$imput_switch.$output_switch.$swvideo.$swmacro.$swremote.$spare.$MAC.$filler.$filler;
-
#-----------------------
-
-
my $response = IO::Socket::INET->new(
-
Proto => "udp",
-
PeerPort => "6454"
-
);
-
-
-
my $poll = IO::Socket::INET->new(
-
PeerAddr=> "2.255.255.255",
-
PeerPort => "6454",
-
Proto => "udp",
-
LocalPort => "6454"
-
);
-
-
-
sub ArtPoll {
-
$poll->send($ArtPoll);
-
print "ArtPoll sent.\n";
-
}
-
-
sub ArtPollReply {
-
$response->recv($ArtPollReply,250);
-
}
-
-
&ArtPoll;
-
&ArtPollReply;
-
-
-
print "<hr>";
-
-
if ($ArtPollReply != null) {
-
print "ArtPollReply: ",$ArtPollReply;
-
} else {
-
print "No data received.";
-
};
-
-
print "<hr>";
-
print $poll,"<br>";
-
print $response;
-
8 5704
your script has a few errors (or the code you posted does anyway) and should not even compile. Use the "warnings" pragma to help diagnose the problems.
use warnings;
The run the script from the command line and reade list of warnings/errors your code generates.
"my" variable $ID masks earlier declaration in same scope at script line 17.
Bareword found where operator expected at script line 58, near "$nump ort"
(Missing operator before ort?)
Unquoted string "ort" may clash with future reserved word at script line 58.
Bareword found where operator expected at script line 59, near "$sw remote"
(Missing operator before remote?)
Unquoted string "remote" may clash with future reserved word at script line 59.
Unquoted string "null" may clash with future reserved word at script line 86.
syntax error at script line 58, near "$nump ort"
I got all those warning fixed but i still have my original problem. So if anyone can help me please do, Thank you.
OK, post your current code.
-
#!/usr/bin/perl
-
print "Content-type:text/html\n\n";
-
-
use IO::Socket;
-
#use strict;
-
-
my $header = 'Art-Net';
-
my $space =' ';
-
my $Prover = chr(0x0e);
-
my $filler = chr(0x00);
-
my $ttm = chr(0x02);
-
my $pad_len_18 = 18;
-
my $pad_len_64 = 64;
-
my $pad_len_34 = 34;
-
-
#---------------ArtPollReply Buffer--------------------------------------------------
-
my $ID = $header.$filler;
-
my $OpCode = $filler.'!';
-
my $IP = chr(0x02).chr(0x00).chr(0x00).chr(0x02);
-
my $Port = chr(0x36).chr(0x19);
-
my $vers = chr(0x02).chr(0x04);
-
my $subsw = chr(0x00).chr(0x00);
-
my $oem = chr(0x02).chr(0x10);
-
my $UBEA = chr(0x00);
-
my $status = chr(0xd2);
-
my $ESTA = chr(0x4c).chr(0x41);
-
-
my $short_name = 'Test';
-
my $long_name = 'Test Node 1';
-
my $report = 'Node is working.';
-
-
$short_name = $short_name.$filler x ( $pad_len_18 - length( $short_name ) );
-
$short_name = $short_name.$filler x ( $pad_len_18 - length( $short_name ) );
-
-
$long_name = $long_name.$filler x ( $pad_len_64 - length( $long_name ) );
-
$long_name = $long_name.$filler x ( $pad_len_64 - length( $long_name ) );
-
-
$report = $report.$filler x ( $pad_len_64 - length( $report ) );
-
$report = $report.$filler x ( $pad_len_64 - length( $report ) );
-
-
my $numport = chr(0x00).chr(0x08);
-
my $port_type = chr(0xc0).chr(0xc0).chr(0xc0).chr(0xc0);
-
my $imput_status = chr(0x80).chr(0x80).chr(0x80).chr(0x80);
-
my $output_status = chr(0x80).chr(0x80).chr(0x80).chr(0x80);
-
my $imput_switch = chr(0x10).chr(0x11).chr(0x12).chr(0x13);
-
my $output_switch = chr(0x00).chr(0x01).chr(0x02).chr(0x03);
-
my $swvideo = chr(0x00);
-
my $swmacro = chr(0x55);
-
my $swremote = chr(0xaa);
-
my $spare = chr(0x00).chr(0x00).chr(0x00).chr(0x00);
-
my $MAC = chr(0x00).chr(0x00).chr(0x00).chr(0x00).chr(0x00);
-
#----------------------------------------------------------------------------------
-
-
#-------ArtPoll-------
-
my $ArtPoll = $ID.$filler.$space.$filler.$Prover.$ttm.$filler;
-
#-------ArtPollReply----
-
my $ArtPollReply = $ID.$filler.'!'.$IP.$Port.$vers.$subsw.$oem.$UBEA.
-
$status.$ESTA.$short_name.$long_name.$report.$nump ort.$port_type.$imput_status.$output_status.
-
$imput_switch.$output_switch.$swvideo.$swmacro.$sw remote.$spare.$MAC.$filler.$filler;
-
#-----------------------
-
-
my $response = IO::Socket::INET->new(
-
Proto => "udp",
-
PeerPort => "6454",
-
);
-
-
-
my $poll = IO::Socket::INET->new(
-
PeerAddr=> "2.255.255.255",
-
PeerPort => "6454",
-
Proto => "udp",
-
LocalPort => "6454",
-
);
-
-
sub ArtPoll {
-
$poll->send($ArtPoll);
-
print "ArtPoll sent.\n";
-
}
-
-
sub ArtPollReply {
-
$response->recv($ArtPollReply,250);
-
}
-
-
&ArtPoll;
-
&ArtPollReply;
-
can you please start using the code tags to post your code.
I don't know if it is a copy and paste problem, but the code you posted still has errors:
Bareword found where operator expected at script line 58, near "$nump ort"
(Missing operator before ort?)
Unquoted string "ort" may clash with future reserved word at script line 58.
Bareword found where operator expected at script line 59, near "$sw remote"
(Missing operator before remote?)
Unquoted string "remote" may clash with future reserved word at script line 59.
syntax error at script line 58, near "$nump ort"
with those errors corrected, I can't determine why your script is not working.
Yeah those errors are just copy paste errors. But the script runs just fine except i need to receive the datagram packet that is being sent back to me that looks like the ArtPollReply buffer and i dont know if im using the recv command wrong but when it just empties out my buffer when the scipt runs.
Sorry mate, I have little experience in this area. I just do not know what the problem could be, hopefully someone else will have a suggestion, or try asking on another forum.
OK thanks but i might have the solution when i use ord() on the string it gives me the first interger as a dec how would ido that to all the intergers in the string.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Rad |
last post by:
Im trying to lauch a small perl program in cygwin which listens for
arguments on a specified port.
When executing this line (18) ;
my $sock = new IO::Socket::INET(LocalPort => $DAEMONPORT,...
|
by: whetham63 |
last post by:
When I run this on my network at home and on my network at work it runs fine.
When this is run at a clients network I am receiving a after the
first packet is received(There are 2 packets...
|
by: bobano |
last post by:
Hi everyone,
I am writing a POP3 Client program in Perl. You connect to a POP3 Server and have a running conversation with the mail server using commands from the RFC 1939 Post Office Protocol....
|
by: Mr. Beck |
last post by:
Hello,
Please Help.....
I have been working with some tcp/ip socket communication within a C#
program recently. Basicly, I have a program (myProblemProgram) that has a
socket connected to...
|
by: kardon33 |
last post by:
How would i receive an incoming UDP packet in perl with IO::SOCKET::INET???
|
by: Dimbeswar Pathak |
last post by:
I got an error message
"use" not allowed in expression at client.pl line 2, at end of line
syntax error at client.pl line 2, near "use IO::Socket::INET"
Execution of client.pl aborted due to...
|
by: clemima |
last post by:
Hi,
i have a script that listens on a port for simple text messages and then
executes sql to a remote mssql database . The script is started via crontab .
There are 2 problems :
1 . The line to...
|
by: pplers |
last post by:
use IO::Socket;
my $path= "http://website.com/aaa.php";
print q(
__________
-/* Script v1.0 *\-
------------------
);
|
by: john2357 |
last post by:
I can not use the LWP module, and must use IO::Socket. Using 'Wireshark' and Mozilla and passing in the parameters below I get a valid reply. However Wireshark shows HTTP needs to be 1.1 and that the...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |