SerialConnection component

  1. 8 months ago

    Martin K

    23 Nov 2019 Czech Republic

    In the new version software R2.1 is the new component SerialConnection, which should be used instead of component Serial. In the new component I didn't found, how is possible to directly write (set) the name of used ComPort. In the old component Serial, it was posible -> Serial.SerialPort=System.SerialPort("COM3").
    How is possible to directly write the name of used ComPort in the new component SerialConnection ?
    In the forums and helps I found only how to detect name of ComPort from index value.

  2. Krzysztof M

    23 Nov 2019 Silesia, Poland
    SerialConnection.Device = SerialDevice.WithName("COM3")
  3. 7 months ago

    Martin K

    28 Nov 2019 Czech Republic

    Thank you very much, but I have next one problem with opening Com Port. In the help is:

    SerialConnection1.Connect -------------------------------- this command doesn't work, like is wrote in the help
    MessageBox("The serial connection is open.")
    Catch error As IOException
    MessageBox("The serial connection could not be opened.")
    End Catch

    The consequence of the command "SerialConnection1.Connect" is error message "You must use the value returned by this function". In the help it looks like the command, why is needed returned value ? When I'll use e.g.:

    Dim ii as Boolean
    ii=SerialConnection1.Connect ---------------- then the line is without errors, but every time the result is False, even if the selected ComPort exist.

    Please does anybody know, how create command Connect, or it is software bug in a new version ?


  4. Krzysztof M

    28 Nov 2019 Silesia, Poland
    Edited 7 months ago

    That's a known bug. So far in my code I just use dummy variable to store the result:

      Dim dummy As Boolean = SerialConnection1.Connect
    # some code to communicate with serial port
    Catch error As IOException
    # error handling code
    End Try

    EDIT: relevant feedback cases: Feedback Case #57945 Feedback Case #57838 Feedback Case #57844

  5. Derk J

    28 Nov 2019 Testers, Xojo Pro

    You can also use the "Call" operator before any function that returns any value if you want to ignore the result

or Sign Up to reply!