Ruby Decode Bytes from COM Port Module
Posted: Sat Nov 21, 2015 8:45 am
Hi,
I am using the Com Port Module to read in byte (hex) data from a digitizing tablet (and 16 button cursor). been banging my head for too long on this and need a bit of Ruby help please.
I can read in the data but I know I am not getting the next values correctly. If I was using BASIC or C++ I would do this differently, but need to learn Ruby since it is in Flowstone my favorite programming system ever !
Here is my code, The digitizer tablet data comes in as 6 bytes of hex data, one of which contains a 1 in the MSB position to sync off of... Normally I would keep reading the input value until I get a "sync" then grab the next 5 bytes (and of coarse the first byte) for a total of all 6 bytes. But I cannot seem to get this working without the ability to jump back to a "label" (like in BASIC or C) and repeat the test to see if I have "sync".
The next issue is getting the next bytes in order... storing them in an array, then decoding them (still to be done), then repeating this process to keep streaming the data in, in order to be able to track the digitizer cursor and then when a user presses one of 16 cursor keys, that data coordinate pair is saved... ruby in Flowstone seems to be a little different than some of the online tutorials especially with inputting and outputting data, at least for me...
Here is a snapshot of the code but it is not syncing or putting the values into the array properly ??? All of the output values are the same, and thus the event is not getting updated with the most current data value.
Thanks for any Ruby help please
Aron
I am using the Com Port Module to read in byte (hex) data from a digitizing tablet (and 16 button cursor). been banging my head for too long on this and need a bit of Ruby help please.
I can read in the data but I know I am not getting the next values correctly. If I was using BASIC or C++ I would do this differently, but need to learn Ruby since it is in Flowstone my favorite programming system ever !
Here is my code, The digitizer tablet data comes in as 6 bytes of hex data, one of which contains a 1 in the MSB position to sync off of... Normally I would keep reading the input value until I get a "sync" then grab the next 5 bytes (and of coarse the first byte) for a total of all 6 bytes. But I cannot seem to get this working without the ability to jump back to a "label" (like in BASIC or C) and repeat the test to see if I have "sync".
The next issue is getting the next bytes in order... storing them in an array, then decoding them (still to be done), then repeating this process to keep streaming the data in, in order to be able to track the digitizer cursor and then when a user presses one of 16 cursor keys, that data coordinate pair is saved... ruby in Flowstone seems to be a little different than some of the online tutorials especially with inputting and outputting data, at least for me...
Here is a snapshot of the code but it is not syncing or putting the values into the array properly ??? All of the output values are the same, and thus the event is not getting updated with the most current data value.
Thanks for any Ruby help please
Aron