67nate Posted June 30, 2007 Report Share Posted June 30, 2007 I'm trying to error catch incomming code. It comes in as a hex representation of ascii. (05 30 36 44...) To make sure nothing gets lost the last to bits before the termination bit are a Xor calculation of all previous bits. The problem is the formatting, here's an example: Incomming string: 0546 4630 5244 3030 3030 3738 3243 0D Xor of relevent bits = 2C This is one bit I now need to seperate the bit to match it with the 32 43 for 2 C. I can't figure a way to seperate it since it is just 1 bit. Thanks, Nate Quote Link to comment
xavier30 Posted July 1, 2007 Report Share Posted July 1, 2007 QUOTE(67nate @ Jun 29 2007, 09:34 PM) I'm trying to error catch incomming code. It comes in as a hex representation of ascii. (05 30 36 44...) To make sure nothing gets lost the last to bits before the termination bit are a Xor calculation of all previous bits. The problem is the formatting, here's an example: Incomming string: 0546 4630 5244 3030 3030 3738 3243 0D Xor of relevent bits = 2C This is one bit I now need to seperate the bit to match it with the 32 43 for 2 C. I can't figure a way to seperate it since it is just 1 bit. Thanks, Nate Hi Nate I think you are mixing bits and bytes a bit. (if you didnt just type bit instead of byte??) in any case, to clarify things: your "XOR'ed" value 2C = 3243 in HEX as you stated, which is 2 bytes, thous 16 bits (therefore the name "hex" = 16) and is written to the memory like this (Pretending this is a 16 bit system, though computers usually have 32/64 bits). (msb) 0011 0010 0100 0011 (lsb) = 3243(HEX) = 2^13 + 2^12 + 2^9 + 2^6 + 2 + 2^1 + 2^0 =12867(Decimal value) =50 67(Decimal value written in byte pairs) And another thing: Every string character represents a byte, and therfor 8 bits. so when you have 2 characters "2C" it is actually 2 bytes, 2x8=16 bits (im guessing there is no "NULL" terminator in your string since its in hex?? Gah, im starting to confuse myself...) Provided a picture and a small .vi, trying to sort things out... Hope this poor explanation vas somewhat useful.. im not good at explaining stuff... Cheers X http://forums.lavag.org/index.php?act=attach&type=post&id=6279''>http://forums.lavag.org/index.php?act=attach&type=post&id=6279'>http://forums.lavag.org/index.php?act=attach&type=post&id=6279 Quote Link to comment
67nate Posted July 3, 2007 Author Report Share Posted July 3, 2007 Hi again, thanks for the help but I want to get the 2C and the 3243 in the same format so I can see if they are equal. I can't open your VI (I have only 7.1) so I'm not sure if those wires went down to do anything. I'm also not sure how to attach a picture. Anyway here is what I have I want string and XOR checksum to be the same. Thanks, Nate P.S. I could add a screen shot if someone told me how. What would the URL be? Quote Link to comment
orko Posted July 3, 2007 Report Share Posted July 3, 2007 QUOTE(67nate @ Jul 2 2007, 06:53 AM) Hi again, thanks for the help but I want to get the 2C and the 3243 in the same format so I can see if they are equal. I think that you are looking for the "Hex String to Number" vi that is located in the String/Number conversion pallette. Here is your VI modified to use this with your U16 hex string: http://forums.lavag.org/index.php?act=attach&type=post&id=6285 http://forums.lavag.org/index.php?act=attach&type=post&id=6286 You could also just compare the output of the "Hex String to Number" vi with the output of your FOR loop and bypass the unnecessary conversion to strings, unless that is needed for some other reason. QUOTE(67nate @ Jul 2 2007, 06:53 AM) P.S. I could add a screen shot if someone told me how. What would the URL be? Use the attachment manager below the posting tool to upload pictures/VI's and attach them to your posts. It should be below the area that you type your message and above the "Post Options" and emoticons. Cheers! Quote Link to comment
67nate Posted July 7, 2007 Author Report Share Posted July 7, 2007 I'm trying to split the string. If I imput my own string I want to be able to split the check and append it to my string. So if the Xor check is 23 (one byte) I want to be able to change it to 32 33 (two bytes the first being the 2 and the second being the 3) If there is a way to change the xor check from a hex string to a decimal sting without converting the value [23 (hex) = 23 (decimal)] that would work great. Thanks, Nate Quote Link to comment
67nate Posted July 17, 2007 Author Report Share Posted July 17, 2007 For the benifit of other readers: I solved the problem by using math to split the number in to two different numbers rather than splitting the string. Quote Link to comment
orko Posted July 17, 2007 Report Share Posted July 17, 2007 QUOTE(67nate @ Jul 16 2007, 12:28 PM) For the benifit of other readers: I solved the problem by using math to split the number in to two different numbers rather than splitting the string. Sorry I didn't get back to you sooner. For some reason your post didn't show up as new last time I checked the boards... I see what you're trying to accomplish now. When you're dealing with hex characters you are dealing with 4-bit words, which can be tricky if you don't split them up correctly, since the lowest numerical type we have is 8-bit. Even though it looks like you have a solution, here's the way I would attack this: http://forums.lavag.org/index.php?act=attach&type=post&id=6370 http://forums.lavag.org/index.php?act=attach&type=post&id=6369 (LV 7.1.1) Basically, I'm taking the byte out of the XOR loop and splitting it up into its 4-bit hex components, then converting their hex values to strings. Hope this was a help to you, Joe Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.