Hi John,
I don't think you have to specify RX and TX direction is it handled by the read/write commands. I don't know how much help this well be but this this a serial setup for Arduino communication (sends about 40 bytes to PC on a timer roughly every 200mS) so might give you idea of how to configure it...
Code:
'===== Configure Com Port ===== OK 15/03/20 (Called from From1 Load event)
Public Sub Configure_ComPorts()
Try
'Clear ComPort Listbox
Form1.ComPort_ComboBox.Items.Clear() 'Belt & Braces as should be clear anyway
'Populate Comport Combobox with active comports
For Each sp As String In My.Computer.Ports.SerialPortNames
Form1.ComPort_ComboBox.Items.Add(sp)
Next
'Set Defualt comport - NOTE COM1 is usually PC internal so default is to last Comport found
If Form1.ComPort_ComboBox.Items.Count > 1 Then
Form1.ComPort_ComboBox.SelectedIndex = (Form1.ComPort_ComboBox.Items.Count - 1) 'Display Name of Last Comport Found
Else
Form1.ComPort_ComboBox.Text = Form1.ComPort_ComboBox.Items.Item(0) 'Display Name of only Comport Found
End If
'Configure Comport with Arduino compatible settings
Form1.SerialPort1.PortName = Form1.ComPort_ComboBox.SelectedItem 'Set Comport to Open - Default last Active ComPort in list
Form1.SerialPort1.BaudRate = 19200 'Set Baud Rate
Form1.SerialPort1.DataBits = 8 'Set Number of Fata Bits
Form1.SerialPort1.Parity = IO.Ports.Parity.None 'Set Parity used
Form1.SerialPort1.StopBits = IO.Ports.StopBits.One 'Set Stop bits used
Form1.SerialPort1.Handshake = IO.Ports.Handshake.None 'Set Handshaking used
Form1.SerialPort1.Encoding = Text.Encoding.Default 'Set text encoding used
Form1.SerialPort1.ReadTimeout = 10000 'Set Timeout in Milliseconds - 10 seconds recommended
Form1.SerialPort1.NewLine = vbCr 'Set Newline identifier - Arduino specified
Form1.SerialPort1.ReceivedBytesThreshold = 38 'Set minimum number of Bytes to recieve before Recieved Event is Triggered - 38 in minimum that should be sent
Tx_Data = "e" 'Set default Tx data value to the stop value in case sent before full control established
End If
Catch ex As Exception
If Serial_Errors < 3 Then
MsgBox(ex.Message, Title:="Configure Com Ports Error") 'Display error Message
Serial_Errors = Serial_Errors + 1
End If
End Try
End Sub
To read data from the port my code is
Code:
Thread.Sleep(4) 'Wait to ensure all data is recieved
Rx_Data = SerialPort1.ReadLine
Which is running in a background worker (multi-threading), you do not need to do that. For my code the read is triggered by the RecievedBytesThreshold in the initial setup above and can be handled as you see fit within
Code:
'=== Serial Port Data Recieved Interrupt Handler === OK 25/06/2018
Private Sub Serial_Data_Recieved() Handles SerialPort1.DataReceived
End Sub
which is automatically called (like an interrupt) one the receive threshold is met. In my case it starts the the data parsing background worker although use of the RecievedBytesThreshold may not be applicable the PPS application.
To send data to the serial port my code is
Code:
SerialPort1.Write(Tx_Data)
This may not be the best serial code but was written last year so should be compatible with the current version of VB.
As for the other issue I am not sure how you would solve that, VB tries to update to the current version but I think code written pre 2003 is to far removed for it to cope.
You could try a find (entire solution) to see what makes use of/setting for the "Working Directory", "Command", "OutDir" and "PostBuildEvent" as that may give a clue as to what it is for and thus how to re-write it to be compatible with VB2019.
From this is looks like it may be trying to start and pass commands to the command prompt which you may be able to do with something like
Code:
Process.Start("someApp.exe", "arg1 arg2")
.
you could also just try setting the Working directory to a known folder, i.e
Code:
WorkingDirectory = CurDir 'Set to the current (project) directory) or the now preferred
WorkingDirectory = My.Computer.FileSystem.CurrentDirectory = "Drive:\FolderName"