04-11-2024 08:09 AM
Hello experts,
I want to send a HEX command to serial port device through NI visa and i use Simple serial program. How can i send HEX command to device.
Solved! Go to Solution.
04-11-2024 08:16 AM - edited 04-11-2024 08:27 AM
Just switch your string control to Hex display mode:
Then you will get hex representation inside:
04-11-2024 08:33 AM
Hi experts,
How can send HEX command 0X0211EE0X03 to NI-VISA write? I know that I can write click on the string box and convert it to HEX. But I want to know should I input HEX command as an array or as a write buffer?
04-11-2024 08:38 AM
@Sina6611 wrote:
I want to send a HEX command to serial port device through NI visa and i use Simple serial program. How can i send HEX command to device.
I've seen way too much confusion of "hex commands", so I have to ask what you mean by this? There are two main ways I've seen this defined (along with a couple of really weird ways):
1. Raw/binary/hex data - You are sending raw values, with no connection to ASCII what so ever.
2. ASCII Hex - You are sending ASCII characters that, in normal display, look like hexadecimal values.
If the raw, changing your string controls and constants to Hex display (and make the Display Style visible) will make your life 1 billion times easier.
If you are just getting into serial communications, I very highly recommend watching this video: VIWeek 2020/Proper way to communicate over serial. The second half gets into the raw/binary/hex formats, and you need to be a lot more careful than with ASCII protocols.
04-11-2024 08:43 AM - edited 04-11-2024 08:53 AM
Actually, I want to send the following HEX command:
0X0211EE0X03
but I want to know, should it be as an array or as a write buffer?
04-11-2024 09:08 AM
@Sina6611 wrote:
Actually, I want to send the following HEX command:
0X0211EE0X03
but I want to know, should it be as an array or as a write buffer?
If you know the full command, just use a string with the Hex Display. If you need to build up the message with calculated values, etc., I will most often use Flatten To String on the values and then Concatenate String to put everything in the right order.
With that said, I very highly encourage you to watch the video I linked above. Raw/Binary/Hex protocols need a lot more care than is shown in the Simple Serial Port example in order to make sure you are reading exactly one message.
04-12-2024 06:26 AM
Hello everyone,
I want to send a command to a serial device. The connection works, but it sends false commands. Can anyone say what is the problem? Command is 0X0211EE0X03
04-12-2024 06:36 AM - edited 04-12-2024 06:38 AM
Hi Sina,
@Sina6611 wrote:
Hello everyone,
I want to send a command to a serial device. The connection works, but it sends false commands. Can anyone say what is the problem? Command is 0X0211EE0X03
Well, we don't have your VI, we don't have your hardware/device, we don't have a manual for your device…
What I can say from your image:
Did you already watch this video?
And PLEASE don't create multiple threads for the same question/problem!
04-12-2024 06:54 AM
thank you for your answer.
My message is 0X0211EE0x03
How can is send it to device?
04-12-2024 07:06 AM - edited 04-12-2024 07:12 AM
Hi Sina,
@Sina6611 wrote:
thank you for your answer.
My message is 0X0211EE0x03
How can is send it to device?
No need to ask the same again and again:
I repeat from my previous message: show the radix/display style for each numeric/string control/constant used for building your message string! (After showing the radix it's much easier to set/use the correct radix…)
Btw. you should write "0x02 0x11 0xEE 0x03" to make clear EACH byte is written in hexadecimal encoding! You present a string without any spaces in between, one "0X" and one "0x" (uppercase/lowercase X), the "11"/"EE" without any radix at all - all this makes it harder to understand your issue!