I'm working with a Serial device which has some built in special funktions.
Those functions are initiated via special characters like "ESC J".
Some of those functions take options with them which can be HEX or DEC characters,
some must be dec characters,bitmask sums for example.
Below are some examples,in BASIC and perl.
Beware that the CHR function does not work as defined with LPRINT and serial connection.
It DOES NOT convert the DEC to ASCII table character, CHR(120) is submitted as DEC 120.
99 percent work just fine just 2 things give me a headache.
my $PORT = 'COM8';
sysopen(USB, $PORT, O_WRONLY | O_APPEND) or die "ERROR: $!\n";
print USB "hello world\n";
print USB "\x1BJ";
print USB "\x96";
print USB "\x1Bi\n";
LPRINT "hello world"; CHR$(&HA);
Both program run fine,
the problem happens if i would do
print USB "150";
the device only takes the 1 and would put 50 in the buffer for printing.
Is there a way to encapsulate DEC values in perl like i can do with HEX values ?.
\x1B is treated as 1 character
150 is treated as 3 DEC characters
BASIC CHR$(150) is treated as 1 DEC character
In the above example i can counter the problem via submitting 150 as HEX, the real problem lies in functions where they demand DEC or STRING as options, like "L1".
Is there a way to encapsulate 150 DEC or L1 string,as it works with BASIC ?
ps: i need this raw low level access,and the device is troubled by more complex communications ;)
psps the device tells me exactly what it received, and how it treated it ;)