Getting Propeller to communicate with VB.NET using SEROUT (BS2_Functions OBJ)
ryfitzger227
Posts: 99
Hey guys.
I'm working on trying to get a Propeller to communicate to a VB.NET program using the BS2_Functions Object from the Object Exchange. I'm fairly new to the Propeller, so I want to make sure that I'm doing everything correctly. Every time I run the program the red light on the QuickStart flashes, so I assume that data gets sent out, but right after that the TextBox on the VB Program stays the same value. Can anyone see what I'm doing wrong??
SPIN
VB.NET
I don't know if I'm doing the Serial Port part on VB the correct way. It's been a while since I've dealt with Serial Ports in VB.NET.
EDIT:
I found the Serial Port code for VB that I used a while back and it works fine with the BS2 using
I'm working on trying to get a Propeller to communicate to a VB.NET program using the BS2_Functions Object from the Object Exchange. I'm fairly new to the Propeller, so I want to make sure that I'm doing everything correctly. Every time I run the program the red light on the QuickStart flashes, so I assume that data gets sent out, but right after that the TextBox on the VB Program stays the same value. Can anyone see what I'm doing wrong??
SPIN
OBJ BS2 : "BS2_Functions" PUB main BS2.start(31,30) pause(10000) BS2.Serout_Str(5,string("Hello World!"),9600,1,8) PUB pause(ms) waitcnt(clkfreq/1000 * ms + cnt)
VB.NET
Public Class Form1 Private WithEvents COMPort As New IO.Ports.SerialPort Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If COMPort.IsOpen Then COMPort.Close() End If Try With COMPort .PortName = "COM7" .BaudRate = 9600 .Parity = IO.Ports.Parity.None .DataBits = 8 .StopBits = IO.Ports.StopBits.One .Handshake = IO.Ports.Handshake.None End With COMPort.Open() Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Private Sub COMPort_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles COMPort.DataReceived TextBox1.Text = COMPort.ReadLine End Sub End Class
I don't know if I'm doing the Serial Port part on VB the correct way. It's been a while since I've dealt with Serial Ports in VB.NET.
EDIT:
I found the Serial Port code for VB that I used a while back and it works fine with the BS2 using
SEROUT 16, 16468, ["Hello World!"]but when I use the Propeller code (above) it doesn't do anything but send a '?' to the computer. Am I using the Prop SEROUT correctly?
Comments
I've not used the BS2 functions, so I'm wondering what the "5" parameter is for ?
BS2.Serout_Str(5,string("Hello World!"),9600,1,8)
Also, you might need to send a carriage return after the string.
Bean
Also, this is bad in a Win Form...
You need a method like the on below to write to the UI from a secondary thread. Your method will work for the most part but it can cause unexpected results from time to time.
Serial comms in vb.net are a bit funky in my experience. Would you mind sharing your vb.net code?