SerialConnection baud different on Linux

Hello

Im working on a Terminal program which is overall working fine. One weird thing coming up to me is that:
SerialConnection1.Baud = 9600 is working fine on Windows and Mac but not on Linux (Ubuntu 18.04)

Linux seems only to accept :
SerialConnection1.Baud = SerialConnection.Baud9600
or
SerialConnection1.Baud = 8 (as defined by Xojos list)

This is sad and will not allow using the same code on all 3 OSs.

Can someone confirm this and why this is so?

[quote=483271:@Farai Aschwanden]
Im working on a Terminal program which is overall working fine. One weird thing coming up to me is that:
SerialConnection1.Baud = 9600 is working fine on Windows and Mac but not on Linux (Ubuntu 18.04)
[/code]
I’m surprised setting it to 9600 works at all anywhere

Use the symbolic constants - it will save you from wondering what the heck 8 means later on
And IF Xojo should ever change those to something else then your code would update and use whatever they redefine it as instead of just breaking because you stuck 8 in there
ie/ suppose they change SerialConnection.Baud9600 to 9600 instead of 8
if Baud actually is the baud rate (and not an index into a list like it is now) then your app, when recompiled, might run at 8 baud if you use a hard coded 8 instead of the symbolic value :stuck_out_tongue:

[quote=483271:@Farai Aschwanden]
Can someone confirm this and why this is so?[/quote]
No idea why Ubuntu would be out to lunch here

Tnx for the answer and I completely agree! The “problem” I have by the symbolic constants (which is working on all 3 OSs) is that in my program you can choose/change the Baud rate in a Popup list in which I have all supported Baud rates listed.

Now the sad point: How do I come from the chosen Popup list value (i.e. 9600) value to the symbolic constant (Baud9600) in order to set it?

Sure, I could create a SELECT/CASE statement over all 16 possible values in order to set the constant value. But this would be a joke.

Currently Im filling up the Popup list with Tags representing the values (0-15).

This would all be obsolete if Linux would support SerialConnection1.Baud = 9600 (could then assign the value from the Popup list).

put the symbolic constants in the tags not the values 0 - 15
its just advice

no idea why it wont work on ubuntu - I dont use Ubuntu nor do I use serial devices so someone else will have to chime in that does

Huh? How then I would be able to assign the symbolic constants to the SerialConnection.Baud?

SerialConnection1.Baud = SerialConnection.???

I don’t think Xojo Basic does allow using variable values for predefined expressions.

SerialConnection.Baud = popupMenu.Rowtag(whatever row was selected )

I can try but don’t think this will work as SerialConnect.Baud accepts only Integer values and therefore not something like “Baud9600”.

Yup, there you go:

Type mismatch error. Expected Integer, but got TextLiteral
SerialConnection1.Baud = “Baud9600”

I have no idea what you’ve done but …

start a new desktop app
put a popup menu on there

add the popups open event and set up your popup something like


Me.AddRow( "300" ) 
Me.RowTag(Me.ListCount-1) = Serial.Baud300

Me.AddRow( "1200" ) 
Me.RowTag(Me.ListCount-1) = Serial.Baud1200


Me.AddRow( "2400" ) 
Me.RowTag(Me.ListCount-1) = Serial.Baud2400


Me.AddRow( "9600" ) 
Me.RowTag(Me.ListCount-1) = Serial.Baud9600

add the changed event
in the put

Dim s As New serial
s.Baud = Me.RowTag(Me.ListIndex)

any time you select an item from the popup the ROWTAG already holds the right “baud” value

really

Aaaah, that way, was not aware of that, tnx!

Btw. “Serial” is deprecated -> SerialConnect

I knew about the deprecation FWIW - former Xojo engineer here :slight_smile:
deprecated ? removed and there are some issues in the replacement that have been reported
https://forum.xojo.com/56406-serialconnection#
https://forum.xojo.com/59410-serialconnection-not-throwing-ioexception/p1#

so you could use Serial and just check the error codes or work around the known issues

Ah, didn’t know :slight_smile:

I was not aware of Serial != ConnectionSerial as the documentation says:

This item was deprecated in version 2019r2.
Please use SerialConnection as a replacement.

Tbh whenever there is a deprecation of a function I try to remove it by it’s replacement - asap. Otherwise I forget it and any other day compiling the code wont work as the deprecated function was removed.

I do get error messages/codes back with SeriallConnect, so (so far) it’s fine for me, all good. Nevertheless good to know there are open issues, tnx!