Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending out in decimal, reading in hex

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?

0 Kudos
Message 11 of 47
(1,778 Views)

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.

0 Kudos
Message 12 of 47
(1,776 Views)

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 13 of 47
(1,776 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 14 of 47
(1,771 Views)

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?

0 Kudos
Message 15 of 47
(1,760 Views)

@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


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 16 of 47
(1,745 Views)

@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.

0 Kudos
Message 17 of 47
(1,725 Views)

I believe I have to use the Add Array Elements function. I'm messing with it.

0 Kudos
Message 18 of 47
(1,720 Views)

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

 

 

0 Kudos
Message 19 of 47
(1,714 Views)

you are not adding checksum bytes when adding an empty array.

You should add the checksum as two independent bytes just like you added the header, but with a second build array after the calculation 

greetings from the Netherlands
0 Kudos
Message 20 of 47
(1,704 Views)