02-26-2016 02:07 PM
I am trying to convert the SimpleReadWrite(located C:\Users\Public\Documents\National Instruments\NI-VISA\Examples\.NET\SimpleReadWrite) C code example for talking to a USB device and I am having some issues, the example work fine it just may be my conversion may be wrong any help would be apreciated.
This is the code I have,
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click Try Dim rscName As String = "USB0::0x0B21::0x0025::4332514C323730353856::INSTR" 'Actaul name of resource Dim rm As ResourceManager = New ResourceManager() mbSession = DirectCast(rm.Open(rscName), MessageBasedSession) Dim textToWrite As String = "*IDN?\n" 'Standard ID query mbSession.RawIO.Write(textToWrite) Me.ListBox1.Items.Add(mbSession.RawIO.ReadString()) Catch ex As Exception GenPrcs.ErrorHndl(ex) End Try End Sub
everything works fine until the mbsession.rawio.readstring and then i get this error
again any help would be much aprriciated. Thanks and have a great day
02-29-2016 02:26 PM
When running an unmodified example were you getting any errors (if so, what were they)?
Are you able to read and write at all with your device?
03-01-2016 06:51 AM
The original runs perfect it is just coded in C and when I convert it I beleive something is missing. I am using the example that National Istruments installs which I have attached.
03-02-2016 01:34 PM
What kind of USB device are you trying to connect to?
03-02-2016 01:50 PM
I am using a Prologix USB to GPIB converter to communicate to a Yokogawa WT310 Power Analyzer. I don't beleive it is a hardware issue since with eh example program attacheced to the previous post it works just fine, I think I am loosing something in the conversion fron C to VB.net becuase the error is a time out error when I sent the command mbSession.RawIO.ReadString().
03-02-2016 01:56 PM
Sorry the previous post is not correct, I am connecting to a Yokogawa WT310 through a USB port and sending standard IEEE GPIB command to it. Sorry for the confusion I am also working on a power supply that uses the Prologix to communicat.
03-03-2016 04:42 PM
I’m assuming you have the correct drivers installed since you said the example code works fine.
Do you have NI Measurement Studio? If you do, you can access a SimpleReadWrite example that’s already converted.
Looking at the error, it appears that nothing is responding to the ReadString(). Is it possible that the instrument name is has an error in it?
03-04-2016 06:47 AM
Ok problem solved, it appears that some spaces were being attached to the name of the resource for no appearent reason, so after adding a trim to the device name it works perfectly. Thank you to all that responded to this question, sometimes it takes questions from others to make youself ask questions and it can lead to the right answers. Thanks and have a great day.
03-07-2016 07:15 AM
I have solved this issue can a moderator mark this as solved. Thank you to all that helped and have a great day.
02-23-2020 06:37 PM
i know this is an old post but I am having the same issue converting the example to VB,net
can some one post the solution for converting the C example to VB,.net.
thanks in advance