0

Serial Sending Garbage

I'm using an HD223 with GPIO pins 3/11 set to their alternate function of serial rx/tx. I wrote a custom plugin that can read serial well enough, but when I try to write something back, the receiving Arduino gets back the first letter or two of what I send, but then some garbage characters. In addition, I'm getting one or more bytes sent across serial when the BrightSign boots. I do not have serial logging turned on. Are there any obvious issues with my plugin? (Sorry, I don't know who to format this as code on this forum)

Function carlSerial_Initialize(msgPort As Object, userVariables As Object, o As Object)
print "carlSerial entry"

CarlSerial = newCarlSerial(msgPort, userVariables)

return CarlSerial
End Function

Function newCarlSerial(msgPort as Object, userVariables as Object)
print "newCarlSerial entry"

print "Before Serial in newCarlSerial"
c = CreateObject("roControlPort", "BrightSign")
c.EnableAlternateFunction(0, "serial1")
c.EnableAlternateFunction(6, "serial1")
print "After Serial in newCarlSerial"

CarlSerial = { }
CarlSerial.msgPort = msgPort
CarlSerial.userVariables = userVariables
CarlSerial.objectName = "CarlSerial_object"

CarlSerial.ProcessEvent = carlSerial_ProcessEvent

gaa = GetGlobalAA()

if gaa.myserial = invalid then
print "Creating myserial"
gaa.myserial = CreateObject("roSerialPort", 1, 115200)
print "Setting myserial port"
gaa.myserial.SetLineEventPort(CarlSerial.msgPort)
print "Done setting up myserial"
end if

return CarlSerial
End Function

Function carlSerial_ProcessEvent(event As Object) as boolean
if type(event) = "roStreamLineEvent" then
serialCmd$ = event.getstring()
if Left(serialCmd$, 3) = "VER" then
gaa = GetGlobalAA()
'print "RECEIVED VERSION REQUEST"
gaa.myserial.SendBlock("llama")
'print "SENT LLAMA"
else
'print serialCmd$
end if
return true
else
return false
end if
End Function

1 comment

  • 0
    Avatar
    Jackson Clemence

    On top of my garbage sending issue: After every time the "SendBlock" line runs, any future reads of the serial port include a leading line feed. No idea why. In other words, when the code starts if I send "food" to the brightsign, it prints out "foo" (left 3 characters) as expected. If I then send "VERSION" it correctly reads the Left three characters as "VER", enters that If block, then sends the garbage string. After that though, if I send "food" to the brightsign it will print out "fo".

Please sign in to leave a comment.