Serial to SerialConnection

I’m trying to update to SerialConnectiion from Serial and I’m not there yet. The port connection is not right. This is a very simplistic connection I’m trying to establish:

Find Port:

[code]Var i As Integer
Var PortName as string

For i = 0 To System.SerialPortCount-1
if System.SerialPort(i).Name = “usbserial-A50285BI” then
CurrentPort = i 'Global Property
PortName = System.SerialPort(i).Name
end
next
Return PortName[/code]

Old Serial code that worked fine:

Var SBuffer As String Me.port = CurrentPort Me.baud = 8 If open Then WriteSerial "reset" pause (10) SBuffer = ReadAll(Encodings.ASCII) End

New SerialConnection Code that needs help:

[code]Var SBuffer As String

Me.device = CurrentPort REM PROBLEM SEEMS TO BE WITH DEVICE=CURRENTPORT
Me.baud = 8

Me.connect

Catch error As IOException
MessageBox(“The serial connection could not be opened.”)

WriteSerial “reset”
pause (10)

SBuffer = Me.ReadAll(Encodings.ASCII)[/code]

Try changing
me.device = currentPort
to
me.SerialPort = System.SerialPort(currentPort)

The super for SerialControlSubClass is SerialConnection but this error occurs:

Type “SerialControlSubClass” has no member named “serialport”

[code]Var SBuffer As String

Me.serialport = System.SerialPort(currentPort)
Me.baud = 8

Me.connect

Catch error As IOException
MessageBox(“The serial connection could not be opened.”)

WriteSerial “reset”
pause (10)

SBuffer = Me.ReadAll(Encodings.ASCII)
[/code]

or… you could just not try to fix what was never broken.
Serial API1 is not going away, who knows what bugs are in API2?
there is no reason to use API2 serial, there is absolutely zero advantage.

Mark

[quote=497062:@Mark Carlton]or… you could just not try to fix what was never broken.
Serial API1 is not going away, who knows what bugs are in API2?
there is no reason to use API2 serial, there is absolutely zero advantage.

Mark[/quote]
Now that was an absolutely perfect answer. I will take that advice.

You don’t assign the serialconnection a serialPort anymore but a SerialDevice.

I tried about every combo I could and still found it to be a mystery, including using SerialDevice. Serial works fine, so be it. Change for the sake of change is not always a good thing. The one thing that frustrates me the most is the limited number of examples in the documentation. Not everyone has been doing this for 20 years.

It would still be nice to figure it out or make a bug report if you can reproduce it. Odd issues like this can leave people scratching their head for hours, new Xojo users are likely to only use the new version of stuff as the documentation does not show the older version. If the new version has a bug they might not know about the old working version to fall back on, this can be very frustrating.

Alex,
what you suggest is absolutely correct, but sadly there have (seemingly) been changes for the sake of it, which appear to have absolutely no reason or rhyme and are not bug free and have very poor, or no updates, to examples or language reference.

Serial, for instance, has worked for years, I can’t imagine what on earth can be improved by changes to it.

without some rational reason from the company to stop using API1 serial class, I won’t be changing use of it, hence I would have no interest in testing a version supposedly to replace it and reporting bugs, newly created.

let the new users do all the QA testing and bug reports, I am just trying to make a living, its also very frustrating that long time users are being ignored and the language reference to the API1 classes are being removed so mythical new users are not confused (as you put it).

lets hope these new users manage to get the search function of the forum to work well enough to find this discussion and it makes them aware that API1 exists, its still perfectly usable and, may actually solve their problem, without wasting a lot of time doing bug reporting, after all we are supposedly using a RAD tool.

if anyone does find a solution, or the bug, then great, report it and amend this thread to suit, it would be very good to see a solution for API2 users if anyone has the time or inclination to do so, lets hope the huge numbers of new users have the time to get that sorted out.

this time I have taken a picture of my reply just so I know its not going to be deleted.

Regards

Mark

[quote=497126:@Mark Carlton]Alex,
what you suggest is absolutely correct, but sadly there have (seemingly) been changes for the sake of it, which appear to have absolutely no reason or rhyme and are not bug free and have very poor, or no updates, to examples or language reference.

Serial, for instance, has worked for years, I can’t imagine what on earth can be improved by changes to it.

without some rational reason from the company to stop using API1 serial class, I won’t be changing use of it, hence I would have no interest in testing a version supposedly to replace it and reporting bugs, newly created.

let the new users do all the QA testing and bug reports, I am just trying to make a living, its also very frustrating that long time users are being ignored and the language reference to the API1 classes are being removed so mythical new users are not confused (as you put it).

lets hope these new users manage to get the search function of the forum to work well enough to find this discussion and it makes them aware that API1 exists, its still perfectly usable and, may actually solve their problem, without wasting a lot of time doing bug reporting, after all we are supposedly using a RAD tool.

if anyone does find a solution, or the bug, then great, report it and amend this thread to suit, it would be very good to see a solution for API2 users if anyone has the time or inclination to do so, lets hope the huge numbers of new users have the time to get that sorted out.

this time I have taken a picture of my reply just so I know its not going to be deleted.

Regards

Mark[/quote]

I wholeheartedly agree with this statement.

Well since xojo changed to api 2.0 all the 20 years of docs become useless. So it’s harder to find the right documentation if you need it.

quote=497156:@Derk Jochems]Well since xojo changed to api 2.0 all the 20 years of docs become useless. So it’s harder to find the right documentation if you need it.[/quote]

And someone may have a better idea why I would want to write code like this:

SequenceTimer.runmode = timer.runModes.Off

Rather then the old way:

SequenceTimer.mode = 0

Just makes programing for me less intuitive. Maybe It’s just an issue for me and there is a good reason for the change.

SequenceTimer.mode = 0

should probably have been altered when the constants were added to

SequenceTimer.mode = Timer.ModeOff

that was before 2012