Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

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.

0 Kudos
Message 1 of 4
(5,744 Views)

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
0 Kudos
Message 2 of 4
(5,726 Views)

Matthew:

 

     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

0 Kudos
Message 3 of 4
(5,724 Views)

Hi,

 

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.

 

Regards,

 

Greg H.

Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(5,714 Views)