Ok what i am trying to do with my script i send a poll and receive a reply and read that reply. I have the Poll work properly but what i need help with is trying to convert the reply from ascii to regular text.
My reply consist of 30 different variables and i need them to be separated. my code so far is. - #!/usr/bin/perl
-
-
print "Content-type:text/html\n\n";
-
use IO::Socket;
-
-
#Poll
-
my $header = 'Art-Net';
-
my $space = ' ';
-
my $Prover = chr(0x0e);
-
my $filler = chr(0x00);
-
my $ttm = chr(0x02);
-
my $ID = $header.$filler;
-
-
my $ArtPoll = $ID.$filler.$space.$filler.$Prover.$ttm.$filler;
-
-
-
#My Reply.
-
my $T_ArtPollReply = pack("A8 S C C C C C C C C C S C18 C64 C64 C C C C C C C C C C C C C C C6 C32",
-
$ID,
-
$OpCode,
-
$BoxAddr,
-
$VersionInfoH,
-
$VersionInfo,
-
$SubSwitchH,
-
$SubSwitch,
-
$OemH,
-
$Oem,
-
$UbeaVersion,
-
$Status,
-
$EstaMan,
-
$ShortName,
-
$LongName,
-
$NodeReport,
-
$NumPortsH,
-
$NumPorts,
-
$PortTypes,
-
$GoodInput,
-
$GoodOutput,
-
$Swin,
-
$Swout,
-
$SwVideo,
-
$SwMacro,
-
$SwRemote,
-
$Spare1,
-
$Spare2,
-
$Spare3,
-
$Style,
-
$Mac,
-
$Filler,
-
);
-
-
$Node_Ip = '2.0.0.1';
-
-
my $poll = IO::Socket::INET->new(
-
PeerAddr => $Node_Ip,
-
PeerPort => "6454",
-
Proto => "udp",
-
LocalPort => "6454",
-
);
-
-
sub ArtPoll {
-
$poll->send($ArtPoll);
-
print "ArtPoll sent.\n<hr>";
-
-
sub Reply {
-
$poll->recv($T_ArtPollReply,250);
-
print $T_ArtPollReply;
-
}
-
&Reply;
-
}
-
-
&ArtPoll;
-
When i run it i try to print the reply but i get[HTML]<br>[/HTML] Art-Net??!??6???̉LATest1?????????????Test Node ?????????????????????????????????????????????????? ????#0001 [0019] Power On Tests Pass?????????????????????????????????€€??????€€?? ??????????????¦?
i know i have to do something with unpack or something but not sure if some one could help me out it would be very helpful.
0 1404 Sign in to post your reply or Sign up for a free account.
Similar topics
by: Johannes |
last post by:
Hi,
I tried to pack eight integer values and one string into one binary
string, which I would like to store in a mysql db.
I encountered two problems doing this:
1)
$this->packed =...
|
by: Sergey Dorofeev |
last post by:
I can use string.unpack if string in struct uses fixed amount of bytes.
But is there some extension to struct modue, which allows to unpack
zero-terminated string, size of which is unknown?
E.g....
|
by: Stacy Mader |
last post by:
Greetings all,
I have a VMS binary file with weather data. The record
on each line is 1xint(8) 12xint(2)
Using the perl unpack function, I can decode the
binary file like this:
<snip>
|
by: p.lavarre |
last post by:
Can Python not express the idea of a three-byte int?
For instance, in the working example below, can we somehow collapse the
three calls of struct.pack into one?
08 12 34 56 80 00
I ask...
|
by: Steve |
last post by:
Are there any gurus of the pack/unpack world out there that can help me
with this one?
I have an encrypted string which I'm reading from a zipped file. It was
written using
pack ( "la" ....
|
by: andmarti |
last post by:
If I build a strict with:
import struct
print struck.pack ('i', 1)
it returns a '\n'.
What's wrong with it???
:(
--
|
by: praveen0437 |
last post by:
hi
i know about format argument in pack and unpack like b h i etc but in some cases i am getting < or = symbols along with them what does they signifies
for example struct.pack( "<cI", 'n',...
|
by: tmp123 |
last post by:
Hello,
Thanks for your time.
After review the "struct" documentation, it seems there are no option
to pack/unpack zero terminated strings.
By example, if the packed data contains: byte +...
|
by: joe shoemaker |
last post by:
If you have the following:
data = unpack('>L', sock.recv(4))
Does this line of code means that incoming data is big endian and
unpack it to endianess of local machine? If local machine is...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |