and, can we send HEX value via Com Port by pandora?
0
RokuAnthony
eaglexp,
To send a string out the serial port, use the BrightScript: "print" comand. To send a non-ascii value, use the chr(value) function. For example:
Print "this string is going to the console which is the serial port"
print chr(65);"B";chr(67) ' prints "ABC"
[edit: I had stated that you must use a version of the software greater than 1.0.72, but this is incorrect. This feature is in 1.0.72]
To change the baud rate, use the roSerialControl object (or the shell cmd). This object controls the RS232 port Baud Rate. It has one interface:
ifSerialControl
• rotBOOL SetBaudRate(rotINT32 baud_rate)
Supported baud rates are:
1800, 2000, 2400, 3600, 4800, 7200, 9600,
12800, 14400, 19200, 23040, 28800, 38400, 57600,
115200
Example:
print "Attempting to change baud rate to 4800"
baud=CreateObject("roSerialControl")
if type(baud)<>"roSerialControl" then print "unexpected error!":stop
okay = baud.SetBaudRate(4800)
print "SetBaudRate(4800) returned: ";okay
end
0
eaglexp
if i want to send a HEX Number, like "4AH",
how to write the scirpt then?
Thanks.
0
RokuAnthony
print chr(&H4A);
The semicolon prevents a CR being appended to the output.
For more info, look up the "print" and the "chr()" functions in the BrightScript Reference Manual which can be downloaded from the support section of our web site.
anthony
0
eaglexp
thanks, i'll try it later.
0
ikwildatjij
Hi,
I am trying to control my projector using the serialport on my hd2000.
and i have to change the baudrate to 19200
I tried the example in this topic but it does not work......
This is in my autorun.bas at this time:
serial = CreateObject("roSerialPort", 0, 19200)
p = CreateObject("roMessagePort")
serial.SetLineEventPort(p)
serial_only:
msg = wait(0,p) ' Wait forever for a message.
if(type(msg) <> "roStreamLineEvent") goto serial_only 'Accept serial
messages only.
serial.SendLine(msg) ' Echo the message back to serial.
print "attempting to turn the projector on"
print chr(67);chr(48);chr(48)
Can someone help me out? <!-- s:roll: --><img src="{SMILIES_PATH}/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /><!-- s:roll: -->
0
RokuTed
ikwildatjij,
In what way does your code not work? How are you testing it?
Have you verified that your serial cable is functional by connecting it to your PC and running the shell?
Also, I noticed that your code uses print statements after attempting to do serial communication. Please note that those print statements will go out the serial port and get sent to your projector.
0
RokuTed
ikwildatjij,
Let me add to the above post. If all that you are trying to do is to send the three bytes out to the projector, all you should need is the following code:
serial=CreateObject("roSerialPort", 0, 19200)
serial.SendBlock(chr(67) + chr(48) + chr(48))
The first line sets the baud rate.
The second line sends the characters.
If you are not waiting for a response from the projector, you do not need to wait for events on the message port.
Note that to connect a BrightSign to a PC, you need to use a "null modem adaptor" which crosses the TX and RX lines.
If you projector connects to a PC with a regular serial cable, then it will also connect to your BrightSign with a normal serial cable. IE, the BrightSign serial port acts like a PC serial port.
0
ikwildatjij
It does so that won't be any problem.
Thx again ! If there's any progress i'll let u know.
Greets Ikwildatjij
0
ikwildatjij
I'm still trying to control my projector via a string through the serial port....
Please advice me on the following.....
in our last posts we discussed about sending strings out via the serial port and how to write it correctly in the script.