#
# Example use of BotSense.bsSerial Module
#
import sys
# create a BotSense client
cli = bsTypes.BsClient('myserial')
# connect to the bsProxy server at the given IP address and default port
try:
bsServer.ServerConnect(cli, serverHostName="192.168.0.34")
print inst
sys.exit(8)
# open a virtual connection to a proxied serial device
try:
hndVConn = bsSerial.SerialReqOpen(cli, "/dev/ttyUSB0", baudRate=115200)
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
print "Example: established virtual connection %d" % (hndVConn)
# write some data
try:
n = bsSerial.SerialReqWrite(cli, hndVConn, "hello dude\n")
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
print "Example: %d bytes written" % (n)
# close the virtual connection
try:
bsSerial.SerialReqClose(cli, hndVConn)
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
# close the connection to the bsProxy server
try:
bsServer.ServerDisconnect(cli)
except bsError.BotSenseError, inst:
print inst
sys.exit(8)
# delete the client
del cli