11-09-2009 12:47 PM
Hi,
Here is my situation: I have a USB to I2C adapter built using a Silabs microcontroller. The physical connection to that is done obviously via an USB cable. I want to send/receive information to/from it using NI-VISA. I created an USB driver for RAW usb device and installed it. Everything works fine and in the Measurement and Automation Explorer I can see my device listed.
Now I have put together the following code to communicate with my USB to I2c module:
#define MAX_CNT 200
ViChar buffer[MAX_CNT]; /* Buffer for string I/O */
ViSession rsrcMgrHandle, instrHandle; /* Communication channels */
ViUInt32 retCount; /* Return count from string I/O*/
int status;
// Open Resources
if ((status = viOpenDefaultRM (&rsrcMgrHandle)) != VI_SUCCESS) { /* Error Initializing VISA...exiting */ return -1; }
if ((status = viOpen (rsrcMgrHandle, "USB0::0x10C4::0x84D6::FF::RAW", VI_NULL, VI_NULL, &instrHandle)) != VI_SUCCESS) {/* Error Initializing VISA...exiting */ return -1; }
//Ask the device for identification
if ((status =viWrite (instrHandle, "*IDN?\n", 7, &retCount)) != VI_SUCCESS) {/* Error Initializing VISA...exiting */ return -1;}
….
….
// Close Resources
if ((status = viClose (instrHandle)) !=VI_SUCCESS) {/* Error ClosingVISA...exiting */ return -1;}
if ((status = viClose (rsrcMgrHandle)) !=VI_SUCCESS) {/* Error Closing VISA...exiting */ return -1;}
I need to transmit a command that in c looks like:
int WriteCmd(unsigned char cmd, int device, int address, int numBytes, unsigned char* buffer)
Can anybody tell me haw would I do that? Any examples of similar programs ?
Many Thanks,
ZZippo
11-10-2009 04:48 AM
11-10-2009 05:38 AM
Thank you muks!
We will keep this one to help Zzippo out.
Kind Regards,
Michael S.
Applications Engineer
NI UK & Ireland
11-11-2009 03:07 AM
Hi,
Sorry for the double post. The formating of my first post was not right and I could not delete the post ....
Thanks,
ZZippo
11-11-2009 06:58 AM
11-23-2009 10:27 AM
Hello ZZippo,
I can see that no replies have been posted here in my absence, I do apologise I should have asked a colleague to keep an eye on it.
Can you let me know how you are getting on and whether this is still an issue? I can have a look at possible solutions and help you myself.
muks, can I ask what your question is referring to?
Kind Regards,
Michael S.
Applications Engineer
NI UK & Ireland