LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ComWrt works explicitly but not when I send buffered commands.

I am having trouble with sending RS232 commands to a mixer.
Here's an example of the code I am using.

If I explicitly send the command it will work.

- ComWrt (1, "\2M01H\r" , 6);

// This command works


But when I read a string from a String control and send a BUFFER with the command it does not work.

-GetCtrlAttribute(panelhandleMain,panelMain_strCOMMAND,
ATTR_CTRL_VAL, cmdstring);
GetCtrlAttribute(panelhandleMain,panelMain_strCOMMAND,
ATTR_STRING_TEXT_LENGTH, &cmdlength);
err = FlushOutQ (1);
Delay(1.0);
cmdstring[cmdlength] = 0;
ComWrt (1,cmdstring,cmdlength);
//This command does not work


Any assistance will be greatly appreciated.


Thanks.
0 Kudos
Message 1 of 3
(2,628 Views)
Hi,

What command are you reading from the text control? if you have a string in your code like "\rTest\n" the compiler will translate this to a string containing the ASCII code for tab(\r) the string "Test" and the ASCII code for end of line. If you read the same string from a control you will have in you string the character "\" + "r" + "Test" + "\" + "n".

Following the example above you cound read the comand out of the control and then replace the 2 characters "\n" with an actual end of line character.

You can use the "view variable value..." tool in HEX to check what are the exact differences between the string that you are sending.

Let me know if you have any further questions on this.

Regards,
Juan Carlos
N.I.
Message 2 of 3
(2,628 Views)
Juan Carlos,
Once again you've solved my problem.

Thanks
Dave
0 Kudos
Message 3 of 3
(2,628 Views)