0

Capture Serial Return with BrightScript plugin

Hello,

 

I've gotten pretty far without needing to post but there is a wall that I can't seem to get past. I'm creating a plugin that sends and receives Serial Commands. The idea is to send a command out, and listen for a return so I can output something all within a function. Or if possible, after sending a command, return to ProcessEvent and listen for the return. Currently, I have sending serial commands working nicely.

 

I've looked and waded through many documentations and posts about how to do something similar. I can't seem to get any to work.

 

Currently in my code I have a function that handles the command input and sends the command. In my pluginbuilder, I have initialized a

Plugin.SerialPort = CreateObject("roSerialPort", 0, 9600)

In my function, I have

byteArray = CreateObject("roByteArray")

byteArray.FromHexString(command)
o.SerialPort.SendBlock(byteArray)
o.SerialPort.Flush()

command is the hex string, o is the plugin array.

 

However to capture a return value is where I get stuck. I've read using roStreamLineEvent would help me, but I can't seem to get that to be the event.

 

Any help would be great.

3 comments

  • Avatar
    Lyndon Official comment

     

    why are you using the plugin to listen for serial events  vs the presentation? is it because you need to listen for wildcard values? If you have serial event in your presentation, you don't need to create the serial object separately. You can use the serial object that the presentation creates. But, you have to have serial events in your presentation. 

    is the serial being sent to the brightsign terminated with a carriage return? or is it unterminated?

     

  • 0
    Avatar
    Joseph

    The command's return value has about 32 different combinations and it would be easier to handle the value programmatically rather to individually write them in through BrightAuthor. I'm sure writing them all in individually would be fine, but for future presentations, it would not be viable.

     

    I'm not sure what you mean by terminated with carriage return/unterminated. I'm very new to using anything with Serial/Hex Commands.

     

    UPDATE:

    I figured out my problem... Kinda... I didn't pass through bsp in the pluginbuilder. I'm not entirely sure why that fixes the problem as there doesn't seem to be any clear explanation in the documents. I got some expected response depending on the command. Some returns are not fully coming in which is a new issue.

    What I mean by my new issue is that a command should return 11 bytes, but only 7 is being returned. I'm not sure if this is an issue with not waiting long enough for the roStreamLineEvent, or if the return is not fully returning what is to be expected.

     

    Any help on that would also be useful. Otherwise, this problem is mostly solved.

     

    UPDATE2:

    The issue seems to be with SetLineEventPort(). I'm able to get it working with SetByteEventPort() and getting the expected values and a few extras consistently. I tried getting SetByteArrayEventPort() to work but it locks up during the pluginbuilder. I'm not sure how to carry on from that, but otherwise my issues have been solved.

  • 0
    Avatar
    Lyndon

     

    Can you send the actually plugin into with the support ticket?

    also, Lineeventport works so long as the terminating character of what's being sent matches what the EOL character is set to. Do you know if your serial content is terminated with a  CR or LF or something else?

     

     

Please sign in to leave a comment.