NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
cdl3
Posts: 11
0 Kudos

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.

Member
mudson
Posts: 87
0 Kudos

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
Member
cdl3
Posts: 11
0 Kudos

Re: RS-232 via Camera Link

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

Active Participant
Greg-H
Posts: 208
0 Kudos

Re: RS-232 via Camera Link

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
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page