Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

GPIB device class read fails with .NET

Even with simple read/write example application I will always get "Length cannot be less than zero" exception on device read. At NI-Spy log read command show correct response. Any ideas?
0 Kudos
Message 1 of 13
(5,806 Views)
Hello,

If you can post the following I'll take a closer look:

1. The language you are using (C#, VB ?)
2. The import or using statement you are using appropriate for the language.
3. The open, write, read, and close statements

It sounds like you are using NI-488.2 calls; have you tried NI-VISA? You should be able to get and use the default resource manager and then open a GPIBSession to communicate over your GPIB.

Either should work (NI-488.2 or NI-VISA calls); repost if you are still having problems!

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 2 of 13
(5,789 Views)
Quick note:

Post the NI-Spy log as well if you can 🙂

Thanks,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 3 of 13
(5,789 Views)
Actually I'm using this example C:\Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\GPIB\SimpleReadWrite\CS. I only try to send *idn command and read response.

SimpleAsynchronousReadWrite example worked without problems so I modified my program to use async read an now it works. Still it is quite strange that simple thing like this do not work!

I have 488.2 2.3 version driver software.
0 Kudos
Message 4 of 13
(5,785 Views)
Hello,

I see, so the fundamental issue seems to be with synchronous reads as opposed to asynchronous. Although I cannot look closer at this immediately; I'll definitely play with it in the coming week! I suppose the most important thing in the short term is that your program is now functional 🙂

Best Regards and Happy New Years!

JLS
Best,
JLS
Sixclear
0 Kudos
Message 5 of 13
(5,768 Views)
Hello,

I will try this out today and let you know! If you try anything in the mean time repost!

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 6 of 13
(5,745 Views)
Hello again,

No problems with the example... have you tried again since posting?

Repost; I think we can get the example working for you if you'd like!

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 7 of 13
(5,742 Views)
Now I located the actual reason why synchronous ReadString fails. This is because device writes responses with terminating NULL character. If I modify it to exclude NULL read works. So there is something wrong at 488.2 .NET library with string handling.
0 Kudos
Message 8 of 13
(5,724 Views)
Hello,

Just want to confirm so I can actually try this; by NULL character you mean hex value = 0x00 correct?

I'll force a null character and see if I can get the same behavior!

Best Regards,

JLS
Best,
JLS
Sixclear
0 Kudos
Message 9 of 13
(5,708 Views)
Yes with NULL I mean hex value = 0x00.
0 Kudos
Message 10 of 13
(5,695 Views)