NI Home > Community > NI Discussion Forums

Measurement Studio for VC++

Showing results for 
Search instead for 
Do you mean 
Posts: 11

RS-232 via Camera Link

I need sample code that enables RS-232 communcation via Camera Link. I wrote code that searches for all COM ports. opens each port, sends a camera command, and waits for a response. I am opening each port as if it was a standard RS-232; is this a bad assumption? Any help would be appreciated. Thanks.

Posts: 114

Re: RS-232 via Camera Link

Hello cdl3,


A few questions:

Are you getting any kind of response on those serial lines, or are they timing out?

Are you using one of National Instruments' Camera Link cards?
What kind of response can you get from  Measurement & Automation Explorer?


Best regards. 

Matthew H.
Applications Engineer
National Instruments
Posts: 11

Re: RS-232 via Camera Link



     I am trying to communicate with an NI PCI-1429e card. I verified that I can do this with a 3rd-party program whose source I do not have, and I need to duplicate this functionality in my VC++ code. As far as I can tell, the command is not being sent. Referring to the code below, nSent=0 is displayed in my diagnostic text box. I verified video with the Measurement & Automation program, but I did not see any capability to set parameters via RS-232. Any guidance would be greatly appreciated.



    int error ;
    uInt32 nSerial, size ;
    Int32 nRead=0, nSent=0 ;
    char response[9] ;
    char name[64] ;
    Int8 *reply ;
    Int8 buffer[] = { 0x49, 0x73, 0x65, 0x03, 0x3F, 0x04, 0x00, 0x28, 0x0D } ;
    char text[128] ;

    unsigned int    bitsPerPixel;
    DWORD            dwThreadId;
    // Create the event that needs to be signaled when we
    // wish to stop the acquisition.
    HStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
    if (!HStopEvent) return ;

    // Create the thread that is responsible for shutting
    // down the acquisition
    HStopThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) StopThread, (LPDWORD) &HStopEvent, 0, &dwThreadId);
    if (!HStopThread) return ;

    // Get the interface name
    GetWindowText(HIntfName, name, 64);

// Get the interface name
//    GetWindowText(HIntfName, name, 64) ;
    errChk(imgInterfaceOpen(name, &Iid)) ;  // Verified that Sid and Iid look reasonable
    errChk(imgSessionOpen(Iid, &Sid)) ;
    errChk(imgGetAttribute (Sid, IMG_ATTR_GETSERIAL, &nSerial)) ;  // Also verified that nSerial looks reasonable

    size=9 ;  // Size of buffer
    nSent=imgSessionSerialWrite(Sid, buffer, &size, 1000) ;

  sprintf(text, "nSerial: %d  nSent: %d", nSerial,nSent) ;
  SetWindowText (HSerialOut, text);  // Shows nSent=0, so no bytes sent

Active Participant
Posts: 210

Re: RS-232 via Camera Link



What third party program are you using?


The serial communication on the framegrabber is not going to be directly accessable through a standard COM port.  You can access the camera attributes through serial but this is done with our Vision Software.  If you just open a standard COM port and try to talk to the framegrabber it will not work.  I would suggest using the IMAQ drivers.




Greg H.

Applications Engineer
National Instruments