[Gambas-user] Serial Port Write Error Problem and USB

Daniel Campos danielcampos at ...282...
Sun Jul 3 19:17:20 CEST 2005


Hi:

It seems it is a low-level problem, I mean something happens in the 
Linux Kernel
when removing or adding an USB device... or may be the hot-plug system 
from your distribution,
I think the thing you can do from a Gambas program (or a C program 
working with serial
port devices through the standard interface) is trying to detect and 
recover from the problem:

1) You can do

TRY WRITE

instead of

WRITE

2) If the system does not recover the link between the serial port 
device and the PC, you can
do (pseudocode):

TRY WRITE

IF ERROR THEN

    TRY CLOSE #SerialPort
    (OPEN AGAIN THE SERIAL PORT)

END IF

Regards,

D. Campos


nando escribió:

>Bemoit, Daniel
>
>I have a serial port program that currently is configured for 
>/dev/ttyS0 and it runs fine.
>
>On the same machine, I have a USB serial port adapter.
>When plugged in it is /dev/ttyUSB0
>
>While the serial port program is running, when I remove or attach
>the USB serial port, a WRITE ERROR occurs with /dev/ttyS0 which is odd!!
>
>I can tell you where there error occurs in the Serial Port Program
>which is taken from the Serial Port program Example in Gambas.
>
>PUBLIC SUB Write_Serial (a as string)
>
>IF Sport.Status = Net.Inactive THEN
>
>   Message ("Open port first!")
>
>ELSE
>  
>   WRITE #Sport, a, Len(a)        <------WRITE ERROR OCCURS HERE
>
>ENDIF
>
>END SUB
>
>It only happens with adding or removing USB things - not just serial ports
>but USB mouse and USB Keyboard and USB touch screen too.
>
>I certainly hope the USB subsystem is playing with open com ports.
>
>-Fernando
>
>
>-------------------------------------------------------
>SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
>from IBM. Find simple to follow Roadmaps, straightforward articles,
>informative Webcasts and more! Get everything you need to get up to
>speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
>_______________________________________________
>Gambas-user mailing list
>Gambas-user at lists.sourceforge.net
>https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
>  
>





More information about the User mailing list