botsense  3.2.0
RoadNarrows Client-Server Proxied Services Framework
BotSense.bsSerial Python Module

The bsSerial module under the BotSense python package provides python applications an interface to communicate with proxied serial devices. The underlining compiled extension module _bsSerial.so library provides the provides the shim between python calling conventions and the C libbsclient_serial.[a,so] library.

See also
BotSense.bsSerial
Example:
#
# Example use of BotSense.bsSerial Module
#
import sys
import BotSense.BotSenseTypes as bsTypes
import BotSense.BotSenseError as bsError
import BotSense.BotSenseServer as bsServer
import BotSense.bsSerial as bsSerial
# 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")
except bsError.BotSenseError, inst:
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