[Gambas-user] Serial Port Change Events Not Working after Upgrade to Karmic

Benoît Minisini gambas at ...1...
Tue Dec 1 21:28:04 CET 2009


>    Thanks for the suggestion Ricardo.
>    I have already compiled G2.18 from source onto Ubuntu 9.04. The
>  application was working fine on Ubuntu 9.04 with G2.8 but fails with
>  G2.18, so this makes  me think that there is a problem which may have been
>  introduced between G2.8 and G2.13 (the binary on Ubuntu 9.10 which doesn't
>  work). Regards,
>    Tony..

You are right, and I think I understand what happens:

I have noticed that SerialPort callback took too much CPU, because it was 
using polling on the serial port file descriptor. 

So I fixed it by awaken it only when there is some data to read... Mistake! 

I didn't understand that all DTRChange, DSRChange... events are not detected 
by the kernel. So Daniel (who wrote the code) had to use polling to be able to 
detect the changes.

By removing the polling, I was able to raise the Read event without burning 
CPU, but all *Change events were not raised anymore!

Now I have to find a good fix, but I have never used a serial port, so I need 
some enlightenment (no, I won't run E17...)

- Why do you need detecting DTR,DSR... changes?
- How are these events related to flow control and the FlowControl property?

The last question is not innocent. the FlowControl property takes three 
different values: Hardware, Software, Both. 

I'm thinking adding a fourth value, "None", that means the user does not care. 
In that specific case, I will not poll, and *Change events won't be raised.

So you will be able to decide:

- Setting FlowControl to None. You will get the Read event only, but you won't 
burn CPU power.

- Setting FlowControl to any other value. You will get all events, but you 
will have to poll.

This change would be compatible with the current SerialPort interface.

Otherwise, for Gambas 3, maybe I will add a new property to define how much 
polling is needed.

What do serial port people think about that?

-- 
Benoît Minisini




More information about the User mailing list