09-23-2013 12:42 PM
Ok, so here is my issue.
I am pulling parameters from our SQL database, and the values are read in as U16 Decimal Integers.
I then have to put the parameters into a packet of data and send out over the serial port as Hex.
This work fine, except for two of the commands, where the programmers decided to have the "paypload" of the packet as BCD instead of the hex value.
So if I put the number straight into my packet creator like all the other commands I get the wrong command.
For example, I am setting a date, and want it set to 31. So I read 31 (integer, u16) from the database. I then put it into my packet creator (adds header, checksum, etc) and it changes the 31 to 1F (hex).
But the command wants me to send the 31 itself.
So how to I change a number (31) from decimal/integer to Hex, but keep the same number? It should be 31 from the database, but also 31 needs to be hex value I send into the packet creator.
09-23-2013 12:58 PM
09-23-2013 01:20 PM
I use the Build Packet "converter" to add in the Header, and checksum. So if I skip that, it wont add in the checksum/header, causing the device not to accept it.
The output is sent as a HEX string.
09-23-2013 01:25 PM - edited 09-23-2013 01:29 PM
Here is a screen shot of the code, maybe that helps.
The command packet indicator is set to display as Hexidecimal.
The payload is standard decimal. So somehow before I enter the 31 into the payload, I want to somehow "trick" labview to thinking it is a hex value, or I have to change it to 49, so it gets output as 31.
09-23-2013 01:32 PM
11-28-2013 02:10 AM
Dennis, thank you for your replies so far, I apologize for the delay in getting back to you.
Engineering has made another change.
So the payload has some values that need to be converted to hex, and come values that do not.
Parameter A = input is an int (12345678),output needed for the command in Hex (12345678)
Parameter B = input is a string (varchar) (ABCD), output needed for the command in Hex
Parameter C = input is an int (13), output needed for the command in Hex (0D)
Parameter D = input is an int (29), output needed for the command in Hex (29)
So the payload may have portions of it that need converting and others that should be passed through, but just as hex instead of int, but of the same value.
I apologize if I am not making it clear.
11-28-2013 02:50 AM
Hi Kenny_K,
I'm not sure of what u're trying to do. But, if u know the parameter's data type and how it should be may be u can use simple case structure and convert the data accordingly.
I did a raw brute force method to suit ur requirements ( i'm not sure if this is what u need 😞 )