Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Sending out in decimal, reading in hex

It would be easiest to simply build an array of the length and data, do not include the header data.  Calculate the checksum based on that array.  Then do a final build array with the header data, previously build array (length and data), and the newly calculated 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
0 Kudos
Message 21 of 47
(1,831 Views)

@crossrulz wrote:

It would be easiest to simply build an array of the length and data, do not include the header data.  Calculate the checksum based on that array.  Then do a final build array with the header data, previously build array (length and data), and the newly calculated checksum.


Here's the thing I can't seem to progress on, in order for the size to be calculated, it must factor in the checksum elements as well. The user shouldnt have to enter elements for the size, or checksum. The way the code is now, you have to enter the last two checksum elements in order for the size to be correct.

0 Kudos
Message 22 of 47
(1,816 Views)

So I guess the way it would be is...

 

User enters data

 

calculate checksum

 

calculate size

 

add header

 

send out

0 Kudos
Message 23 of 47
(1,816 Views)

The checksum should be a default size of 1 byte or 2 byte or whatever.

That should be known ahead of time.

 

 

0 Kudos
Message 24 of 47
(1,814 Views)

Checksum has a low and high byte, so 2 bytes right?

0 Kudos
Message 25 of 47
(1,808 Views)

Correct.  Since we know the checksum has 2 bytes, simply add 2 to the array size before adding it to the array.

 

Spoiler

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
0 Kudos
Message 26 of 47
(1,806 Views)

I see. So what's happening is:

 

Data is entered, then finds array size and adds 2 elements to it, then splits it to get our high/low bytes, then the header, data, and checksum are built into the array, and sent out.

0 Kudos
Message 27 of 47
(1,798 Views)

@Demetri90 wrote:

I see. So what's happening is:

 

Data is entered, then finds array size and adds 2 elements to it, then splits it to get our high/low bytes, then the header, data, and checksum are built into the array, and sent out.


Exactly!  And as you already know, you have to convert the byte array into a string so you can send it out of the COM port.


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 28 of 47
(1,793 Views)

Awesome, my uncle (the engineer) was using it and everything seems to be working so far. Is it possible to have a toggle switch trigger a set of commands to send to the board? We have an led on the board but it takes a few commands to get it lit/un lit. I just want to be able to flick a switch on Labview and have it turn on/off.

0 Kudos
Message 29 of 47
(1,788 Views)

Look into the event structure.  You will want the Value Change event for your button.

 


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 30 of 47
(1,777 Views)