in reply to Re: using sprintf to print binary data collected from the serial port
in thread using sprintf to print binary data collected from the serial port

Thank you to you and the others. The responses have been very helpful.

I am still having trouble with the if() conditionals. Error messages such as "Argument "^C" isn't numeric in numeric eq(==) at (file_name) line (line_num)" suggest that I am both correctly receiving the serial data and that I am correctly "substr"-ing the data. But that leaves me a little confused and lost. As far as I know Perl does not have "int" and "char" data types like the C language. So, since I don't think data types exist (am I wrong?) I don't know of a way to convert data types.

I could try "thinking strings" and use "eq" and hope to find escape sequences for all byte values from 0x00 to 0xff. This seems like a huge amount of work to create a huge failure.

I could use "ord" to convert data to ASCII-HEX digits and do my comparisons to "A", "C", "F3", etc. This seems like it would probably work but it seems like using a bulldozer to move an ant hill.

Any suggestions on both how to write the code and what is going on? My "this is impossible in Perl" response means that this is a good chance to learn something.

Thanks,
Bruce

P.S. Is there a proper term for items such as "F3" that I want to display? I called it ASCII-HEX and one of the kind people responding to my question called them ALPHA. I have had many discussions of this in the past (big number) years. It is not exactly "HEX" since the "F3" is actually 0x46 and 0x33. I sometimes refer to it as the "ASCII text representation of the hex number" but saying that over and over in a planning meeting (or argument) can get old very fast. Actually, it is not exactly representing a hex number since it is really representing a binary pattern of 11110011. ... Kind of trivial until you have to write a document or coordinate the work of several people.

  • Comment on Re^2: using sprintf to print binary data collected from the serial port