Robert JUHASZ wrote:
> Useful info, I'll do like that.
> Thanks, Robi
>
> 2009/9/19 nando <nand...@nothingsimple.com>
>
>   
>> In my Linux serial port experience, serial port devices are named:
>>
>> /dev/ttyS0..9 and upwards
>> /dev/ttyUSB0..9 and upwards depending on what is plugged in USB.
>>
>> I have done a lot of serial port stuff with Gambas.
>>
>> I know that trying to open then with the serial port control
>> will fail is non-exising port. This error can be detected.
>>
>> It can be possible to open a port as a test to see if it exists, but you
>> may be changing parameters and stealing chars from an existing connection.
>> I've had this happen too....really messes things up.
>>
>> -Fernando
>>
>>
>> ---------- Original Message -----------
>> From: yuhej <robert1juh...@gmail.com>
>> To: gambas-user@lists.sourceforge.net
>> Sent: Fri, 18 Sep 2009 21:08:04 -0700 (PDT)
>> Subject: [Gambas-user]  serial port
>>
>>     
>>> Hello,
>>>
>>> I can see that Gambas can handle the serial ports which is a very good
>>>       
>> news
>>     
>>> for me.
>>> Can someone tell me how can I get the list of the serial ports of my
>>> computer? I wish to make an autodetect function and only allow to select
>>> from the working serial ports.
>>>
>>> Robi
>>> --
>>> View this message in context:
>>>       
>> http://www.nabble.com/serial-port-tp25518421p25518421.html
>>     
>>> Sent from the gambas-user mailing list archive at Nabble.com.
>>>
>>>
>>>       
>> ------------------------------------------------------------------------------
>>     
>>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>>> is the only developer event you need to attend this year. Jumpstart your
>>> developing skills, take BlackBerry mobile applications to market and stay
>>> ahead of the curve. Join us from November 9&#45;12, 2009. Register
>>>       
>> now&#33;
>>     
>>> http://p.sf.net/sfu/devconf
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>       
>> ------- End of Original Message -------
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
>> is the only developer event you need to attend this year. Jumpstart your
>> developing skills, take BlackBerry mobile applications to market and stay
>> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
>> http://p.sf.net/sfu/devconf
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>     
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Gambas-user mailing list
> Gambas-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>   
Hi, try the code below, I have no problems with the serial port.

PRIVATE Sport AS SerialPort
CONST None AS Integer = 0
PRIVATE Rx AS String

PUBLIC SUB Form_Open()
  Sport = NEW SerialPort AS "Sport"
  Sport.PortName = "/dev/ttyUSB0"
  Sport.Speed = "19200"
  Sport.Parity = 0
  Sport.DataBits = "8"
  Sport.StopBits = "1"
  Sport.FlowControl = 0 

  TRY
    Sport.Open()
         
  IF ERROR THEN
    TRY Sport.PortName = "/dev/ttyS0"
      Sport.Speed = "19200"
      Sport.Parity = 0
      Sport.DataBits = "8"
      Sport.StopBits = "1"
      Sport.FlowControl = 0
      Sport.Open()
    IF ERROR THEN
      Message(" Onboard Uart Comm 1 not found -- PROGRAM TERMINATING")
      QUIT
    ENDIF    
 ENDIF
 
END

'******** Get RS232 data ********

PUBLIC SUB Sport_Read()
  SLEEP 0.025

  TRY READ #Sport, Rx, Lof(Sport)
 
  IF ERROR THEN
    GOTO NoRx
  ENDIF
 
  IF Len(Rx) > 8 THEN
    ListBox1.Add(Rx)
  END IF

NoRx:

  Rx = ""
 
END

PUBLIC SUB Form_Close()
  Sport.Close()
  QUIT 
END

Regards
Mike


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to