akujbida has asked for the wisdom of the Perl Monks concerning the following question:
How to force syswrite to write numbers? A number is a numerical value; I do not mean the squiggly lines we draw to represent numbers.
Perl keeps changing the values I try to write, in accordance with its 'does what you expect it to do' philosophy. Three days of official and unofficial documentation, I can't find a solution.
Some examples of Perl changing types behind my back: with this line: syswrite($SERIALPORT, $packet_out)
When I say syswrite 4, I want a number 4 to go out the wire. This must be possible, and discussed already; anyone know how or where? I open the port like this:$packet_out = 4; On the serial wire: 0x34 (which is ASCII code for character 4) $packet_out = '4'; On the serial wire: 0x34 (which is ASCII code for character 4) $packet_out = 0x65; On the serial wire: 0x31 0x30 0x31 (which, bizarrely, is ASCII code fo +r '101' which is a string of the decimal ASCII code for 'e' which has + the ASCII code 0x65)
unless (open ($SERIALPORT, "+<", $comport)) {die "Cannot open $comport +: $!"} system("stty -cstopb hupcl ignbrk -iexten -echo -echoe -echok " . "-echoctl -echoke -crtscts -ignpar cs8 9600 time 5 -icrnl " . "-ixon -opost -isig -icanon -F $comport"); die unless binmode($SERIALPORT, ':raw:bytes'); #numerous variations tr +ied
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: syswrite numbers, not strings
by BrowserUk (Patriarch) on Dec 18, 2014 at 04:43 UTC | |
by akujbida (Acolyte) on Dec 18, 2014 at 06:05 UTC | |
by salva (Canon) on Dec 18, 2014 at 06:16 UTC | |
by akujbida (Acolyte) on Dec 18, 2014 at 06:57 UTC | |
by BrowserUk (Patriarch) on Dec 18, 2014 at 06:18 UTC | |
by akujbida (Acolyte) on Dec 18, 2014 at 07:14 UTC | |
by Anonymous Monk on Dec 18, 2014 at 08:02 UTC | |
| |
by RonW (Parson) on Dec 18, 2014 at 18:48 UTC | |
|
Re: syswrite numbers, not strings
by Anonymous Monk on Dec 18, 2014 at 08:19 UTC | |
by akujbida (Acolyte) on Dec 18, 2014 at 11:54 UTC | |
by RonW (Parson) on Dec 18, 2014 at 23:01 UTC |