Serial port adapter communication problem

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Serial port adapter communication problem

Chien Yu Lin
Dear Micro-Manager group

I wanted to write a device adapter of AOTF from AA optoelectronic. 
The controller of this device connect to PC through USB.
I can sent command through hyperterminal and get the answer from the device.

and the version of MM main program is 1.3.40 (Device API version 32) 
 
When I put the dll file in the root of MM-1.3, it can load the device and initiate it.
The communication problem is from the auto shutter function.
The error message is as below.
It connect to PC by USB and the device manager of winXP told me it is COM6.
Any help would be greatly appreciated.
Thank you in advance!

------------------------------------------------------------------------------------------------------------------------------------
DBG(1612, t:2060:) Device COM6 debug message: Serial port COM6 wrote: L1O0
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Device COM6 message: TERM_TIM
EOUT error occured!
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Error occured. Device COM6. C
OM6. Error code 107 (6b hex).

No answer from serial port
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Error occured. Device CMMCore
::setShutterOpen(). AOTFShutter. Serial command failed.  Is the device connected
 to the serial port?.

java.lang.Exception: Error code: 22
AOTFShutter. Serial command failed.  Is the device connected to the serial port?
.

        at mmcorej.MMCoreJJNI.CMMCore_setShutterOpen(Native Method)
        at mmcorej.CMMCore.setShutterOpen(CMMCore.java:525)
        at org.micromanager.MMStudioMainFrame$7.actionPerformed(Unknown Source)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.JToggleButton$ToggleButtonModel.setPressed(Unknown Source
)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
        at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
   --------------------------------------------------------------------------------------------------------------------------------------
Best Regards,
Chien Yu Lin

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: [micro-manager-general] Serial port adapter communication problem

Nico Stuurman-4
Hi Chien Yu,

I wanted to write a device adapter of AOTF from AA optoelectronic. 
The controller of this device connect to PC through USB.
I can sent command through hyperterminal 

So it has a build-in USB-serial converter?

The error message is as below.
It connect to PC by USB and the device manager of winXP told me it is COM6.
Any help would be greatly appreciated.
Thank you in advance!

------------------------------------------------------------------------------------------------------------------------------------
DBG(1612, t:2060:) Device COM6 debug message: Serial port COM6 wrote: L1O0
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Device COM6 message: TERM_TIM
EOUT error occured!
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Error occured. Device COM6. C
OM6. Error code 107 (6b hex).

No answer from serial port
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Error occured. Device CMMCore
::setShutterOpen(). AOTFShutter. Serial command failed.  Is the device connected
 to the serial port?.

This means that the controller is giving you the expected answer after sending it the L100 command.  If you have evidence of earlier communication between MM and your AOTF, then it most likely means that you either use a wrong terminator in your command, or you are waiting for the the wrong terminator in your GetSerialAnswer call.  It is convenient to prototype these communication sessions using Beanshell, where you can use the MMCore serial port control commands interactively through the mmc object.

Best,

Nico



------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: [micro-manager-general] Serial port adapter communication problem

Chien Yu Lin
Dear Nico,

Thank you for you reply.
It is not USB-serial converter. It is a virtual serial port, which is like ASI stage.
Therefore, I am not sure the communication efficiency between MM and this virtual serial port.

Beanshell is a fine option, and I should need to modify the dll file.
BTW,  there are several missing letters in Beanshell script panel on winXP.
For example, the Beanshell interactive console can not display "bsh%".
It show "  s  %" on the screen. 'b" and "h" are missing.
I found out that the display problem comes from bsh-2.0b4.jar, not MM program. 
I have already tested several winXP PCs, and they all have this problem.
Do you meet this problem before? 

Best,

Chien Yu

2010/1/22 Nico Stuurman <[hidden email]>
Hi Chien Yu,

I wanted to write a device adapter of AOTF from AA optoelectronic. 
The controller of this device connect to PC through USB.
I can sent command through hyperterminal 

So it has a build-in USB-serial converter?

The error message is as below.
It connect to PC by USB and the device manager of winXP told me it is COM6.
Any help would be greatly appreciated.
Thank you in advance!

------------------------------------------------------------------------------------------------------------------------------------
DBG(1612, t:2060:) Device COM6 debug message: Serial port COM6 wrote: L1O0
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Device COM6 message: TERM_TIM
EOUT error occured!
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Error occured. Device COM6. C
OM6. Error code 107 (6b hex).

No answer from serial port
LOG(Fri Jan 22 2010 13:57:41.546000, 1612, 2060:): Error occured. Device CMMCore
::setShutterOpen(). AOTFShutter. Serial command failed.  Is the device connected
 to the serial port?.

This means that the controller is giving you the expected answer after sending it the L100 command.  If you have evidence of earlier communication between MM and your AOTF, then it most likely means that you either use a wrong terminator in your command, or you are waiting for the the wrong terminator in your GetSerialAnswer call.  It is convenient to prototype these communication sessions using Beanshell, where you can use the MMCore serial port control commands interactively through the mmc object.

Best,

Nico



------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general




--
Chien Yu Lin

Ph.D. student

Nonlinear Optics & Biophotonics Lab.
Department of Photonics & Institute of Electro-Optical Engineering
National Chiao Tung University


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: [micro-manager-general] Serial port adapter communication problem

Nico Stuurman-4
Hi Chien Yu,

It is not USB-serial converter. It is a virtual serial port, which is like ASI stage.

That is a USB-serial converter.  A "virtual" COM port is something that appears as a serial port to the OS.  If it comes through a USB port, then there is a USB to serial converter involved (even if you do not see it!).

Beanshell is a fine option, and I should need to modify the dll file.

You can use Beanshell for prototyping and making sure that you have communication with your device working well, but eventually you want to fix the problems that you have in your dll code.

BTW,  there are several missing letters in Beanshell script panel on winXP.
For example, the Beanshell interactive console can not display "bsh%".
It show "  s  %" on the screen. 'b" and "h" are missing.
I found out that the display problem comes from bsh-2.0b4.jar, not MM program. 
I have already tested several winXP PCs, and they all have this problem.
Do you meet this problem before? 

No.  Most likely has something to do with the character set on your computers.  Seems something that can be easily ignored!

Best,

Nico



------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: [micro-manager-general] Serial port adapter communication problem

OscarLin
Dear Nico,

Thank you for your reply!
I have test it through Beanshell, 
and I found out that the answer message from device is too long to read for MM 1.3.
The problem came from getSerialPortAnswer() command.

Furthermore, I also tested another device which give long answer message.
I used ASI stage, and I confirmed the stage work well firstly.
Then I sent command "R X =" to control the stage and the MOVREL functon work well.
Next,I also test ASI stage by command "I X", 
which give you the information about the stage, 
and it gave me the same error message.
The same error message from AOTF and ASI stage was " run-time error : Error code: 22
COM5 COM5. Error code 107 (6b hex)."

The answer message from AOTF is like "L1 F123.456 P20.00 O1 S1"
How can I read long answer from serial port through "CMMCore::getSerialPortAnswer" ? 

Best Regards
Chien Yu

2010/1/23 Nico Stuurman <[hidden email]>
Hi Chien Yu,

It is not USB-serial converter. It is a virtual serial port, which is like ASI stage.

That is a USB-serial converter.  A "virtual" COM port is something that appears as a serial port to the OS.  If it comes through a USB port, then there is a USB to serial converter involved (even if you do not see it!).

Beanshell is a fine option, and I should need to modify the dll file.

You can use Beanshell for prototyping and making sure that you have communication with your device working well, but eventually you want to fix the problems that you have in your dll code.

BTW,  there are several missing letters in Beanshell script panel on winXP.
For example, the Beanshell interactive console can not display "bsh%".
It show "  s  %" on the screen. 'b" and "h" are missing.
I found out that the display problem comes from bsh-2.0b4.jar, not MM program. 
I have already tested several winXP PCs, and they all have this problem.
Do you meet this problem before? 

No.  Most likely has something to do with the character set on your computers.  Seems something that can be easily ignored!

Best,

Nico



------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general




--
Chien Yu Lin

Ph.D. student

Nonlinear Optics & Biophotonics Lab.
Department of Photonics & Institute of Electro-Optical Engineering
National Chiao Tung University


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: [micro-manager-general] Serial port adapter communication problem

Nico Stuurman-4
Hi Chien Yu,

 I found out that the answer message from device is too long to read for MM 1.3.
The problem came from getSerialPortAnswer() command.

The same error message from AOTF and ASI stage was " run-time error : Error code: 22
COM5 COM5. Error code 107 (6b hex)."

Error code 107:
#define ERR_TERM_TIMEOUT 107

The answer message from AOTF is like "L1 F123.456 P20.00 O1 S1"
How can I read long answer from serial port through "CMMCore::getSerialPortAnswer" ? 

Increase the timeout on the serial port from the default 500 msec to whatever time it takes for your device to answer.  You can do so in the Hardware Configuration Manager (port timeout is one of the serial port settings on the second page of the wizard).

Best,

Nico


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: [micro-manager-general] Serial port adapter communication problem

Chien Yu Lin
Dear Nico,

Thank for your reply!
I knew the problem was from the answer timeout.
I have already tried to change timeout to 30 sec.
I still met this problem.
It should not be so slow.
Therefore, I wonder whether the problem comes from serial manager of MM program.
Could you help me?

Best,
Chien Yu

 

2010/1/26 Nico Stuurman <[hidden email]>
Hi Chien Yu,

 I found out that the answer message from device is too long to read for MM 1.3.
The problem came from getSerialPortAnswer() command.

The same error message from AOTF and ASI stage was " run-time error : Error code: 22
COM5 COM5. Error code 107 (6b hex)."

Error code 107:
#define ERR_TERM_TIMEOUT 107

The answer message from AOTF is like "L1 F123.456 P20.00 O1 S1"
How can I read long answer from serial port through "CMMCore::getSerialPortAnswer" ? 

Increase the timeout on the serial port from the default 500 msec to whatever time it takes for your device to answer.  You can do so in the Hardware Configuration Manager (port timeout is one of the serial port settings on the second page of the wizard).

Best,

Nico


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general




--
Chien Yu Lin

Ph.D. student

Nonlinear Optics & Biophotonics Lab.
Department of Photonics & Institute of Electro-Optical Engineering
National Chiao Tung University


------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: [micro-manager-general] Serial port adapter communication problem

Nico Stuurman
Administrator
Hi Chien,

> I knew the problem was from the answer timeout.
> I have already tried to change timeout to 30 sec.
> I still met this problem.
> It should not be so slow.
> Therefore, I wonder whether the problem comes from serial manager of MM program.

The error you describe is caused by the SerialManager adapter not receiving the terminating character(s) that you told it to wait for within the answer timeout of the serial port.  I doubt that this problem has anything to do with the length of the messages.  The Core uses a buffer of 1024 characters for this operation, so if your answer is expected to be longer, than you will run into trouble and should use the readFomrSerialPort(portName) function instead (in which case you need to call this function in a loop and need to check for the end of the answer from the device yourself).

Best,

Nico
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|

Re: Serial port adapter communication problem

Chien Yu Lin
Dear Nico,
 
Do you have ever tested USB chip from Microchip Technology Inc. which act as USB-serial adapter?
It worked well on hyperterminal.
On MM program, it can give command, and device turned on.
Nevertheless, it did not get any answer message from COM port on MM program.
The error code told me that the device overflow(error code : 22), and then the COM port error code is timeout occurred.
The answer was only 23 characters, and it should not be overflowing.
On the other hand, readFomrSerialPort(portName) function let the MM program crash.
 
BTW, the chip from Silicon Laboratories worked well.
It can sent command, and read long answer message which exceed 23 characters.
The problem should come from USB chip or the answer message which serial manager can not recognize.
Do you ever meet a problem like this situation?
 
Best,
Chien Yu Lin

2010/1/26 Nico Stuurman <[hidden email]>
Hi Chien,

> I knew the problem was from the answer timeout.
> I have already tried to change timeout to 30 sec.
> I still met this problem.
> It should not be so slow.
> Therefore, I wonder whether the problem comes from serial manager of MM program.

The error you describe is caused by the SerialManager adapter not receiving the terminating character(s) that you told it to wait for within the answer timeout of the serial port.  I doubt that this problem has anything to do with the length of the messages.  The Core uses a buffer of 1024 characters for this operation, so if your answer is expected to be longer, than you will run into trouble and should use the readFomrSerialPort(portName) function instead (in which case you need to call this function in a loop and need to check for the end of the answer from the device yourself).

Best,

Nico
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general



--
Chien Yu Lin

Ph.D. student

Nonlinear Optics & Biophotonics Lab.
Department of Photonics & Institute of Electro-Optical Engineering
National Chiao Tung University


------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general