03-20-2017 05:53 AM
Hi everyone!
I'm fairly new to LabVIEW and could use some help!
I'm currently working on controlling a servo which needs raw hex data to function properly. I'm using the PS4 controller interface from LabVIEW MakerHub to send the coordinates of the joystick to the servo, attempting to get it to follow the joystick. My problem is; the data I'm sending out through the serial port seems to be represented in ASCII hexadecimal instead of raw data hex. When I attempt to receive sendt data in hexdump on a linux computer it reads my string as ASCII characters and not hex. I have tried all number conversions blocks I could find, as well as displaying part of my string in 'Hex Display' where this is possible. I am able to send the address part of my data packet (the 44 58...-string in attached .pdf-file) in hex format (by using 'Hex Display'), but I simply cannot turn the joystick coordinate into 'actual' hexadecimal characters, so my concatenated string seems to be in ASCII. I have also looked through forum posts I could find on the matter, unfortunately without finding an answer.
The communication protocol i am using is named DexLink.
Documentation can be found here: https://goo.gl/LNtRZr
Any help is would be greatly appreciated!
03-20-2017 06:26 AM
Try using Flatten Into String.
03-20-2017 06:48 AM
If I am using this correctly, no guaranty that I am, it does not make a difference. I am still sending ASCII to the serial port and receiving the data as ASCII.
03-20-2017 07:07 AM - edited 03-20-2017 07:13 AM
Well, the serial port will send a sequence of 1 and 0 🙂 seperated in 8 data bits and some more bits at the beginning and end. So it seems that you have one representation of your data coded in HEX, wheter it is a U8 array with display format set to hex or a string set to /hex display and you want to send the binary value.
The VISA write to the serial port always wants a string.
If you have a string control set to hex display , you can just send it to the VISA write.
If you have an array of U8 values, there is a convert byte array to string vi.
The attached vi show some ways how to enter data ...
I like the last one, the advanced display properties allow a onthefly conversion with integer values 🙂
Reading the serial will give you a string (and a string is just an array of U8 values) you can convert to a array of bytes , and recombine them in the way you need.
03-20-2017 07:11 AM
@NTNUstudent wrote:
If I am using this correctly, no guaranty that I am, it does not make a difference. I am still sending ASCII to the serial port and receiving the data as ASCII.
You are sending STRINGS. Now what data is in the string is what matters. When you use the Number To Hex String, that is encoding the data into an ASCII format. When you use Flatten Into String, you are just reinterpreting the data as a string (ie the raw binary value is not changed).