Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

write series of 0x0 in GPIB

Highlighted

Hi,

 

How  0x0 can be wriiten to GPIB, i have a requiremnt tro write a series of 0x0's.

i may not be able to use this "ibwrt(cpi_handle,\x0\x0\x0\x0,4)" since the 0's are dynamic from a file.

 

since the ASCII equilent is NULL am not able to stor it in char array as well

please suggest a way to do this.

 

Thanks in advance

0 Kudos
Message 1 of 4
(2,592 Views)
Highlighted

You could use an unsigned char array. The \0 characters aren't a problem if you don't use string functions ,which use \0 as termination character for handling that array. 

The real problem is how to fill the array  from your file. That depends on the exact format of your file. If it is binary you could  use fgetc() to read the file and fill the the array characterwise.Often Scanfile() with the right format string ( have alook at the examples for the Scan functions in the CVI help) will work, too.  But without more knowledge about the format of your data file we can't give more help.  

0 Kudos
Message 2 of 4
(2,584 Views)
Highlighted

Hi,

Let me be very simple with my question here,

i want to tansmit for continious zero in my GPIB so i asssigned the 0's as follows

 

chardata[0]=0;

chardata[1]=0;

chardata[2]=0;

chardata[3]=0;

chardata[4]=NULL;

ibwrt(cpi_handle.chardata,4);

 

once i assigned the zero like this its becoming NULL and i see no data in chardata array.

so am not able to send the continious zeros until i do "ibwrt(cpi_handle."\x0\x0\x0\x0",4)" which i canot so

please help me in this,am stuck with this issue

 

Thanks in advance

 

0 Kudos
Message 3 of 4
(2,543 Views)
Highlighted

How do you view the array ? If you are using the debuggers "string display", you will see only the data up to the first zero if you don't enable Options->Display Entire Buffer and you will see nothing if you are using Format->ASCII( Use decimal or hexadecimal instead) 

And you don't need to assign NULL as last character . Ibwrt() takes the number of characters to send as parameter and doesn't need a NULL ats Termination character. 

Just try to run in interactuive execution window and put a breakpoint in front of the second statement

static unsigned char data2[5] = {0};
data2[0] = 0 ;

When viewing it  with default options , it looks like in the attached first screenshot, with options changed it looks like in the second screenshot

Download All
0 Kudos
Message 4 of 4
(2,538 Views)