Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-IMAQ Serial Read/Write

Hello,

 

As I was reading through previous questions and answers people have had I have come to find out the question I want to ask is that the answer is unsupported and there are no examples. So I will just ask the question and just hope someone responds back. 

 

Equpiment:

FrameGrabber: PCI-1429

Camera: Piranha 3 Line scan camera

Development: Visual Studio C++ (6.0)

NI Camera Configuration Wizard (2.0.1)

 

My objective is to create a program quite similar to a component in NI Camera Configuration Wizard's Serial Settings Test and Read. In the Test and Read I am capable of sending commands to my camera and receiving a reponses back. The reason why I would like to create a program rather than just use the wizard is due to a cap on how much information can be received from the camera. For example sending a Get Camera Parameters or "gcp" for short to the camera the wizard will only report back 1/3 of all its information. It is roughly 463 bytes. I understand that this is alot of information and the wizard was not designed to be a flexible tool, but rather a testing component. This is the reason why I want to create a more flexible tool to diagnosis my camera better. I would like to recreate this component, but make the received bytes back to be as flexible as possible in other words to receive whatever the camera wants to send regardless of its size.

 

WIth all that being said I have successfully gotten to a point where I can send and receive information from the camera, but I am not getting everything I am asking for. For instance when I send the GCP command as I have aforementioned I get the response back of "OK>" exactly as expected, but I do not get what I have asked for which is all camera parameters. No matter what command I send to the camera it will always tell me the "OK>" as expected, but nothing else. Keep in mind this command works correctly with the NI Camera Configuration Wizard. 

 

Here is an analogy of my problem.

Me: Camera send me some info about yourself.

Camera: Sure, I will definitly do that.

<long period of time goes by.>

Me: Well, are you going to send me anything?

No responses from the camera.

 

What I have tried...

Due to no examples I have been trying to get what I want by trial and error. I have gotten so close, but I have yet to get where I want to be.

  • imgSessionSerialRead
  • imgSessionSerialReadBytes

For the ReadyBytes I have tried increasing its timeout to 10,000ms. I know this is a bit extreme, but I do not mind waiting to get what I want. In the end all I get is a timeout error. Checking the response I see it only received the "OK>".

 

Where to go...

Well, here I am asking for anyones advice. As I have aforementioned this is unsupported stuff I am getting into and I would like to get this program working to diagnosis this camera. If there is any information that I have missed or over looked let me know. Or even if anybody would like to look at the code I would be more than willing to post as an attachment. 

0 Kudos
Message 1 of 13
(10,120 Views)

Hi cbasmadjian!

 

I looked on the Industrial Camera Advisor and did not find you camera, unfortunately.  However, you can make your own camera file using the Camera File Generator.  What NI vision software do you have installed?  Where did you find the NI Camera Configuration Wizard?

 

Kristen H.

0 Kudos
Message 2 of 13
(10,100 Views)

Kristen,

 

I am sorry you were unable to find my camera. The camera file was created by a National Instruments engineer. I apologize instead NI Camera Configuration Wizard that I mentioned I meant NI Camera File Generator version 2.0.2. I use that software to send/receive the camera just to diagnosis the camera.

 

The software I have installed on the machine is Vision Acquisition Software 8.2.1 and NI-IMAQ 3.7.

 

If there is anymore information that you require please let me know. 

0 Kudos
Message 3 of 13
(10,091 Views)

Hi cbasmadjian!

 

Are you using the Camera File Generator by going to Settings » Serial Settings »Test Serial Settings?  From what I understand, this is what you have done that works, and now want to create your own method of doing the same thing in Visual Studio C++.  Is that correct?

 

Kristen H.

 

 

0 Kudos
Message 4 of 13
(10,059 Views)

Kristen,

 

You are correct! That is exactly what I want to do! The Test Serial Settings functionality is great, but it is limiting on how much can be received from the camera. I would like to make a very simple app that is not limiting. I am just having some trouble recreating that app. Any assistance would be great.

 

Also I would like to do this in Visual Studio C++. If you would like my code or camera file or anything else let me know. 

0 Kudos
Message 5 of 13
(10,056 Views)

Hi cbasmadjian!

 

What limitations have you found with the camera file generator?  How exactly do you want to expand its functionality?

 

Kristen H.

0 Kudos
Message 6 of 13
(10,025 Views)

Great question!

 

If you note that even in its own name that the Test Serial Settings is only a test. Usually test by there very nature have some limitations. With that being said, the limitation I have found with the camera file generator is a size issue. When I send the GCP command (Get Camera Parameters) it responds back with every single customizable parameter that can be adjusted by the user.

 

(Note: The camera file generator will stop at Video Mode. I wrote all the parameters so you can comprehend how much information this camera is sending. This is alot of information and camera file generator says it has only received 452 bytes. My goal is to read every byte of data that the camera sends.)

 

In this case the camera will send back the following information...

 

Camera Model No:

Camera Serial No:

Firmware Design Rev:

CGI Version:

FPGA Design Rev:

UART Baud Rate:

Exposure Mode:

Sync Frequency:

Internal Exposure Time:

Video Mode:                      ******(Note: This is where it stops!)

Region of Interest:

End-Of-Line Sequence:

FFC Coefficient Set:

FPN Coefficients:

PRNU Coefficients:

Number of Line Samples:

Upper Threshold:

Lower Threshold:

Camera Link Mode:

Output Throughput:

Pretrigger:

Analog Gain (dB):

Analog Reference Gain (dB):

Total Analog Gain (dB)

Analog Offset:

Digital Offset:

Background Subtract:

System Gain:

0 Kudos
Message 7 of 13
(10,021 Views)

Hi cbasmadjian!

 

When using imgSessionSerialRead, what type of termination are you looking for and how?  I found some internal documentation discussing serial timeout errors, and it was noted that the read function is not null terminated, so you will have to search for the ASCII termination chracter (typically \r).  It mentions being able to use the function strchr() for this purpose.  

 

Kristen H.

Message Edited by Kristen H. on 04-22-2009 01:46 PM
0 Kudos
Message 8 of 13
(10,014 Views)

Hi Kristen,

 

 According the camera's manual it states <quote> The camera will answer each command with either <CR><LF> "OK>" or <CR><LF>"Error xx: Error Message>"</quote>

 

What I was writing in my code was this...

 

//Clear the internal buffer

imgSessionSerialFlush(...)

 

//Send the GCP command to the camera

imgSessionSerialWrite(...)

 

//Read back the response from the camera

imgSessionSerialRead(...)

 

The typically response that I get back from the camera is only <CR><LF>"OK>" . I do not get the results I ask the camera for. If I execute the imgSessionSerialRead again I will get a timeout warning. I have set my timeout limit to be 5 seconds.

0 Kudos
Message 9 of 13
(10,010 Views)

Hi cbasmadjian!

 

Which termination character are you using?  I think the issue is that "\r" is not being used, and imgSessionSerialRead is timing out because it never reads the termination character signifying the end of the read.  I would double check that.

 

I hope this helps!

 

Kristen H.

0 Kudos
Message 10 of 13
(9,938 Views)