LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CNVDataType for char (network variables)

Hi! Simple question, but I simply cannot find the answer.

 

I'm learning how to use network variables, and am attempting to send a single char. I have managed to send ints and strings successfully, but I don't know what CNVDataType to use for chars. The documentation says "Note that CNVBool refers to a 1-byte boolean type (char or unsigned char), and CNVString refers to a C-style NUL-terminated string.", but to be honest I don't quite understand the reference to a char/unsigned char being a boolean type?

So I tried both using CNVString - which fails since my char does not have a NUL-termination (which I suppose I could add, but it feels like a workaround) - and using CNVBool - which results in the char being interpreted as a bool (true).

I can see that my char is what it's supposed to be through the debugging tool.


The following is the closest I have gotten it to work (excerpt of program):

//Create message to send
char* message = "This is a test message\n";
CNVData data_to_send;

for (int i = 0; i < strlen(message); i++)
{
    char to_send = message[i];
    CNVCreateScalarDataValue(&data_to_send, CNVBool, to_send); //This is the problematic line
    //Put in network variable
    CNVPutDataInBuffer(myWriter, data_to_send, CNVDoNotWait);
}


But this is (not too surprisingly) interpreted as a bool by the system, as seen below.

guybrush_threepwood_0-1611154675378.png

What data type am I supposed to use when sending chars? Or, is the data type not the problem and I'm just missing something else?

Thanks in advance!

0 Kudos
Message 1 of 1
(1,137 Views)