Fighting with SerialConnection

So I am a newbee and having issues with how you tell if a serial port is open or not - Can someone tell me how that is done

this depends on whether you are using API1 or API2.
if your version of Xojo is 19.11 or less it is API1, above will promote the use of API2.

I do not use API2 so I can not answer the question if thats your version.

if you use API1 then I can, here is some code I use that uses my variables to open the serial port.
this code will not obviously run if you copy and paste it, but it shows how to determine the port status.
the language reference is very good , search for ‘Serial’ (API1), look at the ERRORs returned at connection.
you cannot determine post connection, the status of the port.

//open the port and test the error code
//generated by the RS232 Class.
if RS232.Open()=true then//try to open the port
  //on MAC and windows an error number is returned.
  //we can test these and inform the user which error
  //caused the problem.
  //linux just returns false if its not connected.
  //these are the errors available.
  //we can not look at a port and see if its connected.
  //therefore we will record the currently connected port
  //to this global variable and use it to determine if there
  //is a current port open.
  return(true)//good connection
else//a fatal error occured so display to the user
  //SerialPortErrors(port_name)//send "port_name" for the message box
  MsgBox("Error:- The Port '"+target_port_name+"' Could Not Be Opened")

end if

Thank You - unfortunately I am using API2 … trying to be good every time I see that the word depreciated - I am beginning to think every time I see that WORD I will “appreciate” using what has been done in the past

FWIW, I’m using an FTDI USB-to-serial adapter, and I find that the ClearToSend property of a Serial (API 1) object can make a reliable indicator of whether a device is physically connected or not (depending on how CTS is connected and used in your hardware). It may not tell you whether or not you’ve opened the port in Xojo (use variables for that as mentioned by Mark), but it will tell you if the device has been disconnected.

Which platform are we talking about?


depreciated does not mean don’t use, it means choose to get on the big new shiny ride or stick with the original, perfectly working, not needing a completely new set of examples, needs no debugging, relies on the hundreds of hours of existing user experience, has millions of lines of code in operation that the majority of people on this forum have installed on thousands of projects around the world, all of which will still work in 10, 20 years as there is no indication that API1 will ever be removed.

otherwise, use API2, you debug it, you install it in apps you use, and you will suddenly be the foremost expert in the use of serial and API2, time to step up and receive the glory!

a new version of anything is not necessarily ‘upgrading’ using an existing version of something that is completely mature and is proven is not downgrading.

do not dismiss the working API1, try it, write the code you need to get the project working with the help of everyone who has working code , and if you are desperate to move on after that, move the code to API2 if that is important.