Monday, July 30, 2012


Using Serial Camera Functions in a VB6 Form    

  







The Mscomm control must be initialized before using the camera functions. You can do this at design-time by changing the values in the Mscomm control or during run-time by including the following code:

Private Sub Form_Load()
   MSComm1.CommPort = 1
   MSComm1.Settings = "38400,n,8,1"
   MSComm1.InputMode = comInputModeBinary
   MSComm1.InBufferSize = 25000
   MSComm1.InputLen = 25000
   MSComm1.PortOpen = True
End Sub

Here is an example of using  a serial camera function.

Private Sub cmdBaud_Click(Index As Integer)
   txtCameraOutput.Text = "Wait"
   txtError.Text = SetCameraBaud(MSComm1, cmdBaud(Index).Caption)
   txtCameraOutput.Text = CameraHexOutputString(MSComm1)
End Sub

Pressing an indexed cmdBaud button sends that button’s caption “115200” baud rate to the camera, writes “Camera Baud Rate = 115200” in the txtError textbox and writes the returned “76  00  24  00  00” string in the txtCameraOutput textbox.

Note on the current design of the CameraHexOutputString function: This function will read and clear everything in the Mscomm input buffer. First the function checks the buffer size every 0.2 seconds until the buffer size is the same for two consecutive checks. Then the buffer is read all at once and becomes the String value of this function. There is a limit of something over 25,000 on the size of the input buffer in binary mode. I am working on a different way to read the input buffer that allows for bigger input strings. At the moment, this problem is interfering with the saving of JPGs at the largest image size setting. 


No comments:

Post a Comment