11 from sys
import version_info
12 if version_info >= (2, 6, 0):
13 def swig_import_helper():
14 from os.path
import dirname
18 fp, pathname, description = imp.find_module(
'_bsSerial', [dirname(__file__)])
24 _mod = imp.load_module(
'_bsSerial', fp, pathname, description)
28 _bsSerial = swig_import_helper()
29 del swig_import_helper
34 _swig_property = property
39 def _swig_setattr_nondynamic(self, class_type, name, value, static=1):
40 if (name ==
"thisown"):
41 return self.this.own(value)
43 if type(value).__name__ ==
'SwigPyObject':
44 self.__dict__[name] = value
46 method = class_type.__swig_setmethods__.get(name,
None)
48 return method(self, value)
51 object.__setattr__(self, name, value)
53 self.__dict__[name] = value
55 raise AttributeError(
"You cannot add attributes to %s" % self)
58 def _swig_setattr(self, class_type, name, value):
59 return _swig_setattr_nondynamic(self, class_type, name, value, 0)
62 def _swig_getattr_nondynamic(self, class_type, name, static=1):
63 if (name ==
"thisown"):
64 return self.this.own()
65 method = class_type.__swig_getmethods__.get(name,
None)
69 return object.__getattr__(self, name)
71 raise AttributeError(name)
73 def _swig_getattr(self, class_type, name):
74 return _swig_getattr_nondynamic(self, class_type, name, 0)
79 strthis =
"proxy of " + self.this.__repr__()
82 return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
87 except AttributeError:
94 _bsSerial.BS_SER_DEV_NAME_DFT_swigconstant(_bsSerial)
95 BS_SER_DEV_NAME_DFT = _bsSerial.BS_SER_DEV_NAME_DFT
97 _bsSerial.BS_SER_SERVER_MOD_swigconstant(_bsSerial)
98 BS_SER_SERVER_MOD = _bsSerial.BS_SER_SERVER_MOD
100 _bsSerial.BS_SER_CLIENT_LIB_swigconstant(_bsSerial)
101 BS_SER_CLIENT_LIB = _bsSerial.BS_SER_CLIENT_LIB
103 def bsSerialGetMsgName(pClient, hndVConn, uMsgId):
104 return _bsSerial.bsSerialGetMsgName(pClient, hndVConn, uMsgId)
105 bsSerialGetMsgName = _bsSerial.bsSerialGetMsgName
107 def bsSerialReqOpen(pClient, sDevName, nBaudRate, nByteSize, cParity, nStopBits, bRtsCts, bXonXoff, bInitTrace):
108 return _bsSerial.bsSerialReqOpen(pClient, sDevName, nBaudRate, nByteSize, cParity, nStopBits, bRtsCts, bXonXoff, bInitTrace)
109 bsSerialReqOpen = _bsSerial.bsSerialReqOpen
111 def bsSerialReqClose(pClient, hndVConn):
112 return _bsSerial.bsSerialReqClose(pClient, hndVConn)
113 bsSerialReqClose = _bsSerial.bsSerialReqClose
115 def bsSerialReqRead(pClient, hndVConn, uReadLen, rbuf):
116 return _bsSerial.bsSerialReqRead(pClient, hndVConn, uReadLen, rbuf)
117 bsSerialReqRead = _bsSerial.bsSerialReqRead
119 def bsSerialReqWrite(pClient, hndVConn, wbuf, uWriteLen):
120 return _bsSerial.bsSerialReqWrite(pClient, hndVConn, wbuf, uWriteLen)
121 bsSerialReqWrite = _bsSerial.bsSerialReqWrite
123 def bsSerialReqTrans(pClient, hndVConn, wbuf, uWriteLen, uReadLen, rbuf):
124 return _bsSerial.bsSerialReqTrans(pClient, hndVConn, wbuf, uWriteLen, uReadLen, rbuf)
125 bsSerialReqTrans = _bsSerial.bsSerialReqTrans
129 BotSense Serial Python Inline Extensions and Wrappers. 145 import BotSenseCore
as bsCore
146 import BotSenseError
as bsError
147 import BotSenseTypes
as bsTypes
150 """ Get the serial message name. 152 For each (virtual connection, message id) 2-tuple, there can be a known 153 name string (provided the id is valid and an application provides the 157 client - BotSenseTypes.BsClient instance. 158 hndVConn - Virtual connection handle (ignored). 159 msgId - Serial message id. 162 Returns message name string if it can be determined. 163 Otherwise returns 'unknown'. 165 bsTypes.BsClient.ChkClient(client)
166 return bsSerialGetMsgName(client.pClient, hndVConn, msgId)
168 def SerialReqOpen(client, devName, baudRate=9600, byteSize=8, parity='N',
169 stopBits=1, rtscts=
False, xonxoff=
False, trace=
False):
170 """ Proxy server request to establish a virtual connection to an RS-232 173 Raises a BotSenseError exception on failure. 176 client - BotSenseTypes.BsClient instance. 177 devName - Proxied serial device name (e.g. /dev/ttyS0). 178 baudRate - Baud rate. 179 byteSize - Bytes size in bits 5...8. 180 parity - Parity. One of: 'N', 'E', 'O' 181 stopBits - Number of stop bits 1, 2 182 rtscts - Do [not] use hardware flow control. 183 xonxoff - Do [not] use software flow control. 184 trace - Initial message tracing enable(true)/disable(false) state. 187 New virtual connection handle. 189 bsTypes.BsClient.ChkClient(client)
190 hndVConn = bsSerialReqOpen(client.pClient, devName, baudRate, byteSize,
191 ord(parity), stopBits, rtscts, xonxoff, trace)
192 bsError.ChkReturnIsNonNeg(hndVConn,
193 "Client %s: Serial Open request failed." % (client.AttrGetName()))
197 """ Proxy server request to close client's proxied serial device virtual 200 Raises a BotSenseError exception on failure. 203 client - BotSenseTypes.BsClient instance. 204 hndVConn - Virtual connection handle. 206 bsTypes.BsClient.ChkClient(client)
207 rc = bsSerialReqClose(client.pClient, hndVConn)
208 bsError.ChkReturnIsOk(rc,
209 "Client %s: Serial Close request failed." % (client.AttrGetName()))
212 """ Serial request to read from a proxied RS-232 serial device. 214 Raises a BotSenseError exception on failure. 217 client - BotSenseTypes.BsClient instance. 218 hndVConn - Virtual connection handle. 219 readLen - Number of bytes to read. 222 Buffer list of read bytes. 224 bsTypes.BsClient.ChkClient(client)
225 rbytebuf = bsTypes.ByteBuf(readLen)
226 n = bsSerialReqRead(client.pClient, hndVConn, readLen, rbytebuf.getSwigObj())
227 bsError.ChkReturnIsNonNeg(n,
228 "Client %s: Serial Read request failed." % (client.AttrGetName()))
229 rbytebuf.copyFromSwigObj(n)
233 """ Serial request to write to a proxied RS-232 serial device. 235 Raises a BotSenseError exception on failure. 238 client - BotSenseTypes.BsClient instance. 239 hndVConn - Virtual connection handle. 243 Number of bytes written. 245 bsTypes.BsClient.ChkClient(client)
246 wbytebuf = bsTypes.ByteBuf.Clone(wbuf)
247 wbytebuf.copyToSwigObj(len(wbytebuf))
248 n = bsSerialReqWrite(client.pClient, hndVConn, wbytebuf.getSwigObj(),
250 bsError.ChkReturnIsNonNeg(n,
251 "Client %s: Serial Write request failed." % (client.AttrGetName()))
255 """ Serial request to execute a write-read transaction to a proxied 256 RS-232 serial device. 258 Raises a BotSenseError exception on failure. 261 client - BotSenseTypes.BsClient instance. 262 hndVConn - Virtual connection handle. 264 readLen - Number of bytes to read. 267 Buffer list of read bytes. 269 bsTypes.BsClient.ChkClient(client)
270 wbytebuf = bsTypes.ByteBuf.Clone(wbuf)
271 wbytebuf.copyToSwigObj(len(wbytebuf))
272 rbytebuf = bsTypes.ByteBuf(readLen)
273 n = bsSerialReqTrans(client.pClient, hndVConn,
274 wbytebuf.getSwigObj(), len(wbytebuf),
275 readLen, rbytebuf.getSwigObj())
276 bsError.ChkReturnIsNonNeg(n,
277 "Client %s: Serial Transaction request failed." % (client.AttrGetName()))
278 rbytebuf.copyFromSwigObj(n)
def SerialReqOpen(client, devName, baudRate=9600, byteSize=8, parity='N', stopBits=1, rtscts=False, xonxoff=False, trace=False)
def SerialGetMsgName(client, hndVConn, msgId)
def SerialReqRead(client, hndVConn, readLen)
def SerialReqWrite(client, hndVConn, wbuf)
def SerialReqClose(client, hndVConn)
def SerialReqTrans(client, hndVConn, wbuf, readLen)