Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: I need Hex conversion, not!

by AnomalousMonk (Canon)
on Jan 07, 2013 at 22:54 UTC ( #1012126=note: print w/replies, xml ) Need Help??


in reply to I need Hex conversion, not!

Here's a cut-down example of a pack approach to building a socket message. I leave you to fiddle with the checksum until it comes out right; I can never seem to get this sort of thing first-try.

>perl -wMstrict -le "my $SM = 0xfe; my @ADRDSTN = (0x00, 0x09, 0x01, 0x00); my $MID = 0x01; my $MDLH = 0x00; my $MDLL = 0x18; my $EM = 0xFD; ;; my @message = (@ADRDSTN, $MID, $MDLH, $MDLL); ;; my $packed_message = pack 'C*', @message; ;; my $checksum = 256 - unpack '%8C*', $packed_message; ;; my $msg_for_socket = pack 'C a* C C', $SM, $packed_message, $checksum +, $EM; ;; my $msg_for_debug = unpack 'H*', $msg_for_socket; print qq{'$msg_for_debug'}; " 'fe00090100010018ddfd'

Replies are listed 'Best First'.
Re^2: I need Hex conversion, not!
by Anonymous Monk on Jan 09, 2013 at 09:29 UTC

    Thank you for your message but I'll continue with the methods above for now

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012126]
help
Chatterbox?
[marioroy]: Hello all. After several attempts, am able to move forward and will soon release a Parallel:: ForkManager compatible MCE::Hobo:: Manager, also MCE::Hobo::Simple, and refactored MCE::Hobo engine supporting multiple instances. Wait works beautifully.
[marioroy]: MCE::Shared has been refined that it allows sharing Tie::File and hash objects containing {fh} key.
[marioroy]: It's taken so long to take Hobo to a new level. Threads-like and Parallel:: ForkManager management capaiblities.
[marioroy]: This will complete the 4 years in the making and likely time to move on to something els.
[marioroy]: s/els/else.

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2017-05-26 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?