String to Bitfield
-
Hi there!
I am struggling and trying to parse ASCII letter to bit field presentation. I am trying to use "Text Parser" actor with no luck.I have managed to parse text "!6DF8A1" and extract the 4th character.But howto convert letter 'F' to bit field 1111b. Or a letter 'A' to bitfield 1010b and how to get access to those bits. -
Hello,
Best way would be javascript actor, here is the codefunction main() { var text = arguments[0];//input of text text = text.charCodeAt(5);//fifth character ASCII value (decimal) text = text.toString(2);//binary value text = text + "b";//add b return text;//output the text }
And the izzy patch. (but binary for A is not 1010b, is 10000001b!) 2af459-texttobinary.izz
-
Hi again,
This was my first posted problem and I am impressed by the speed of comment and views.
I was a bit unclear when I stated that the letter 'F' should be conversed. Instead I meant hex 'F' should be conversed. That letter contains sensor information of 4 digital channels. Here is the picture of hex 'A':
PS.
I really should learn that javascript :) -
attached is an old school approachfrom what i understood the string you get is a combination of hex values and each 0-F is representing a wordto have a good overview about characters / hex values and bits i would suggest [MacASCII Display](http://www.synergycreations.com/downloads.html) a really nice little tool. -
Hello,
I need to be more specific…
Here is a patch and script doing the taskfunction main() { var out = [];//list declaration var text = arguments[0];//input of text var first = arguments[1];//first letter var last = arguments[2]+1;//last letter text = text.slice(first,last);//choosed letters out[0] = text;//plain output text = parseInt(text,16); out[1] = text;//dec value text = text.toString(2); out[2] = text;//bi value return out;//output the values }
-
@m-theateer
Thank you for your help, but javascript is so more elegant, compact and easy to manage.jacques -
jep js is a big thing, but as you mentioned in the other post, the actors has to grow with the new processing possibilities (midi, tcp send )attached you will find a short test in js-p.sjust saw your 2nd version this is great -
I also like JS. Its just so easy to understand.. and flexible.
However, the native actors will be faster. In cases where you are parsing fast data streams (high baud serial connections etc...)the native actors are going to eat up less cpu.Probably not going to be a common issue, but worth noting for extreme cases. -
Hi again,Problem solved and love them both! Js and original worked both. Yes there is old school approach doing interactive spaces :)I have rs485 network for reliability reasons. I use cheap industrial ADAM modules for polling digital IO. I made a speed test with max 115200 baud. New query was sent immediately after receiving acknowledge message from the IO module. I managed to get 110 query-response in a 1 second with Isadora traditional max 240 cycles. That means 70 digital sensors with polling interval 0.05s.Here is the test rig: