07-09-2012 11:48 AM
Ok, I think I see what's going on. Your code makes the "data array", and then displays the "size" meant to go into the command packet. The engineer told me however that the data might get larger, meaning more elements. Is there a way to get the "data" portion of the packet based on it's changing length?
07-09-2012 11:59 AM
I should have said earlier, but the only thing we are going to be entering is the data portion of the command packet. We enter the data, and Labview will start with header, calculate size, data, and calculate checksum.
07-09-2012 12:01 PM
@Demetri90 wrote:
Ok, I think I see what's going on. Your code makes the "data array", and then displays the "size" meant to go into the command packet. The engineer told me however that the data might get larger, meaning more elements. Is there a way to get the "data" portion of the packet based on it's changing length?
I got the data portion based on how many bytes the packet said there were. So if those two bytes were 0x000A, it would grab 10 bytes for the data. That's what the Array Subset function does. I know the data portion of the packet starts at byte index 4 and the size was given to me in the data size bytes of the packet. So I told the Array Subset to give me the (for the example I gave earlier) 10 elements starting at index 4.
07-09-2012 12:11 PM - edited 07-09-2012 12:12 PM
Oh, I'm going to the wrong direction! Ok, this is easier then. You have the data already defined at an array of bytes, right? Then use the Array Size to get the length of the data array.
07-09-2012 12:29 PM - edited 07-09-2012 12:32 PM
Your icons are different from mine, is it something I'm doing wrong? I attached a picture of the previous code. Also, I'm having trouble figuring out what is what in the .png. Would it be possible to post that bit of code you did?
07-09-2012 01:15 PM
@Demetri90 wrote:
Your icons are different from mine, is it something I'm doing wrong? I attached a picture of the previous code. Also, I'm having trouble figuring out what is what in the .png. Would it be possible to post that bit of code you did?
I don't show my terminals as icons. Everything else looks the same.
Believe it or not, the pictures I have been posting is code in the form of snippets. You can save off the pictures and then drag them onto your block diagram and there's your code.
I'm confused again. Are we trying to build up a packet from the data or are we trying to get the data from a packet? For clearification: packet = Header + Data Length + Data + Checksum
07-09-2012 03:48 PM
@crossrulz wrote:
@Demetri90 wrote:
Your icons are different from mine, is it something I'm doing wrong? I attached a picture of the previous code. Also, I'm having trouble figuring out what is what in the .png. Would it be possible to post that bit of code you did?
I don't show my terminals as icons. Everything else looks the same.
Believe it or not, the pictures I have been posting is code in the form of snippets. You can save off the pictures and then drag them onto your block diagram and there's your code.
I'm confused again. Are we trying to build up a packet from the data or are we trying to get the data from a packet? For clearification: packet = Header + Data Length + Data + Checksum
Wow, didn't know that about the snippets, awesome feature. We are trying to build a packet, so all that would need to be entered from the user is the data portion. I plugged that code in and from what I see works great. Next is calculating the checksum. To calculate checksum, the 00 09 from the last two elements of this command 00 08 00 01 00 00 00 00 00 09 is a result from adding all the values in the command besides the header (AA 55).
Basically we add all the values in each element besides the two header elements, and put the result at the last two elements of the command.
07-09-2012 04:00 PM
I believe I have to use the Add Array Elements function. I'm messing with it.
07-09-2012 09:05 PM - edited 07-09-2012 09:14 PM
Having some trouble. First the array subset, as far as length goes, I'm trying to have it return the length of the packet from index 2 to the end of it minus 2, basically from the size to end of data portion (but for now it's 2 to 7), so this would give me an array without the header and checksums. I then use the add array elements function to get the checksum. Now how would I got about inserting the checksum into the final packet array?
Here's my code so far
07-10-2012 01:29 AM