VDTWrite and machine code

Hi guys,

I'm trying to talk to one of my device via Igor, the standard way to do so is via a custom Labview interface made by the constructor. On this interface each entered command is also displayed for the expert in assembled binary command data, I quote from the manual :

Quote:

Machine Code Display
Expert → A display of assembled binary command data (machine code) is provided as a convenience for developers wishing to communicate with the Scan Controller in binary format. The Machine Code Display shows the translation of the SC2000 assembly language statement entered from the command line after assembly. The Command Byte string is the binary data sent to the Scan Controller, the Machine Code. This is displayed in hexadecimal format with the bytes sent to the Scan Controller in left-to-right order. If the statement entered on the Command Line was a query command, information is provided on the number of bytes to read back and the type of translation to apply to the readback data.


I monitored my operation port and the code displayed is effectively the query sent. for example the ?status command sent the query : FF FF FF FF FF FF FF FF

My question is how can I directly sent those query via Igor ? I've been able to configure the VDTOperationPort2 and VDTOpenPort and I'm able to send query via the port but I can't seem to understand how to send the proper data. I want to send 12 00 01 but the sent data displayed in the monitoring of the port displays different query. I get that it must be a question of choosing the right command but I can't figure out which out should I use.

Thank you for your answer
neogin wrote:
I monitored my operation port and the code displayed is effectively the query sent. for example the ?status command sent the query : FF FF FF FF FF FF FF FF


This seems to be a hexadecimal number. Have you tried to send it by the VDTWriteHex2 command?
VDTWriteHex2/L 0xFFFFFFFFFFFFFFFF
I tried that. The correspondent query sent via the port is : 46 46 46 46 46 46 46 46 where I would like to have directly FF FF FF FF FF FF FF FF. So VDTWriteBinary2 seems to be the solution, but my syntax must be wrong 'cause I don't seem to be able to get the proper query sent.

thanks
G.
neogin wrote:
I tried that. The correspondent query sent via the port is : 46 46 46 46 46 46 46 46 where I would like to have directly FF FF FF FF FF FF FF FF.

Have you added the 0x in front of the Fs? This is important, because otherwise Igor does not recognize the argument as a hex number and you will see the 46s. Try printf "%X\r", char2num("F") on Igor's command line as an example.

Additionaly I took a look in the SC2000 manual. It seems to be necessary to send 9 bytes for the ?status query, 1 for the command itself and 8 for the parameters, see the manual on page 81. You can't do this with just 1 call to VDTWriteHex2 since this command can only sent 2, 4 or 8 bytes. So you have to call VDTWriteHex2 twice.
I just recognized that you can't send 9 bytes with the VDTWriteHex2 operation at all.
I propose to use - as you suggested - the VDTWriteBinaryWave2 operation.
make/o/u/b/n=9 binWave=0xFF
VDTWriteBinaryWave2/type=0x48 binWave
FF is the ASCII hexadecimal representation of a byte with all bits set. If you send 0xFF using VDTWriteHex2, you are sending two bytes each of which are an ASCII F (0x46). This is hex, not binary.

To send a three bytes byte, specifying the values in hex:
VDTWriteBinary2 0x12, 0x00, 0x01

To send a three bytes byte, specifying the values in decimal:
VDTWriteBinary2 18, 0, 1

These two commands send the exact same bytes.

You can also use VDTWriteBinaryWave2 in which case you must store the bytes in a byte wave.

Hi,

Indeed the VDTWriteBinary2 works and I'm now able to send the good query but it still don't work, but I think a a question of coding not related to igor (end of command command).

Thanks guy for the answers
G.
So I pin-pointed my issue, I'm monitoring my RS232 port. When I use VDTWriteBinary2 I got the following : 1.png and I don't get the expected behavior from my device, and when I use the Labview interface made by the constructor I got the following : 2.png.

My so it seems that Igor send byte by byte when the interface sends the whole word ? how do I do the same with Igor ?

Best,
G.
1.png (180.92 KB) 2.png (121.85 KB)
Quote:
My so it seems that Igor send byte by byte when the interface sends the whole word ? how do I do the same with Igor ?


What the dumps show is that VDTWriteBinary2 does a separate write call for each parameter. However, this does not change what is transmitted. The same thing is transmitted whether all in one write call or in separate write calls.

The first thing I see that is suspect in the dump is the 0D byte. 0D is carriage return and is normally sent to mark the end of a line of plain text. It should not be sent in a binary transmission. VDTWriteBinary2 does not send carriage returns. Check to see if you have any other calls, e.g., to VDTWrite2, that should not be there. But VDTWrite2 does not send a carriage return either unless you include it in the str parameter.

What program are you using to monitor these transmissions? What is IRP_MJ_WRITE?
Well, the oD is my idea I was trying if the issue was an "end of command" issue so I tried with adding "0x0d" at the end (it didn't work).

An IRP_MJ_WRITE request transfers data from a client to a COM port. It's the name of the subprocess. To follow transmission I use a serial port sniffer to get the information.

I still don't get it, there must be a difference between using one of many write calls because when it uses only one the device responds, and when it uses several it doesn't. ("it" would be the computer) Is there a way to use one write call ?

Best regards,
Gautier Papon

Quote:
I still don't get it, there must be a difference between using one of many write calls because when it uses only one the device responds, and when it uses several it doesn't. ("it" would be the computer) Is there a way to use one write call ?


Try putting the values in an unsigned byte wave and calling VDTWriteBinary2. For example:

Make/O/B/U temp = {0xFF, 0x01, 0x12}
VDTWriteBinaryWave2 temp


However, it should make no difference to the receiver whether you send the bytes all at once or one-at-a-time.

it seems it does for my device because now it's working ! Thank you very much!

Have a nice day
Best regards
Gautier