mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-21 02:34:16 +00:00
gsmopen: adding libctb-0.16
This commit is contained in:
1 parent
fc4c61570b
commit
282a1885e7
59 files changed
+15449
No files matched your search
@@ -0,0 +1,455 @@
|
||||
import wxctb, sys, re
|
||||
|
||||
DCD = wxctb.LinestateDcd
|
||||
CTS = wxctb.LinestateCts
|
||||
DSR = wxctb.LinestateDsr
|
||||
DTR = wxctb.LinestateDtr
|
||||
RING = wxctb.LinestateRing
|
||||
RTS = wxctb.LinestateRts
|
||||
NULL = wxctb.LinestateNull
|
||||
|
||||
def abstract():
|
||||
import inspect
|
||||
caller = inspect.getouterframes(inspect.currentframe())[1][3]
|
||||
raise NotImplementedError(caller + ' must be implemented in subclass')
|
||||
|
||||
class IOBase:
|
||||
def __init__(self):
|
||||
self.device = None
|
||||
# set timeout to 1000ms (the default)
|
||||
self.timeout = 1000
|
||||
|
||||
def __del__(self):
|
||||
pass
|
||||
|
||||
def Close(self):
|
||||
if self.device:
|
||||
self.device.Close()
|
||||
|
||||
def GetTimeout(self):
|
||||
"""
|
||||
Returns the internal timeout value in milliseconds
|
||||
"""
|
||||
return self.timeout
|
||||
|
||||
def Ioctl(self,cmd,arg):
|
||||
if self.device:
|
||||
self.device.Ioctl(cmd,arg)
|
||||
|
||||
def Open(self):
|
||||
abstract()
|
||||
|
||||
def PutBack(self,char):
|
||||
return self.device.PutBack(char)
|
||||
|
||||
def Read(self,length):
|
||||
"""
|
||||
Try to read the given count of data (length) and returns the
|
||||
successfully readed number of data. The function never blocks.
|
||||
For example:
|
||||
readed = dev.Read(100)
|
||||
"""
|
||||
buf = "\x00"*(length+1)
|
||||
rd = self.device.Read(buf,length)
|
||||
return buf[0:rd]
|
||||
|
||||
def ReadBinary(self,eos="\n"):
|
||||
"""
|
||||
Special SCPI command. Read the next data coded as a SCPI
|
||||
binary format.
|
||||
A binary data transfer will be startet by '#'. The next byte
|
||||
tells the count of bytes for the binary length header,
|
||||
following by the length bytes. After these the data begins.
|
||||
For example:
|
||||
#500004xxxx
|
||||
The header length covers 5 Byte, the length of the binary
|
||||
data is 4 (x means the binary data bytes)
|
||||
"""
|
||||
try:
|
||||
eoslen = len(eos)
|
||||
b=self.Readv(2)
|
||||
if len(b) == 2:
|
||||
hl = int(b[1])
|
||||
b = self.Readv(hl)
|
||||
if len(b) == hl:
|
||||
dl = int(b)
|
||||
# don't left over the eos string or character in the
|
||||
# device input buffer
|
||||
data = self.Readv(dl+eoslen)
|
||||
# check, if the binary data block is complete
|
||||
if data[dl] == '#':
|
||||
# not complete, another block is following
|
||||
for c in data[dl:dl+eoslen]:
|
||||
self.PutBack(c)
|
||||
|
||||
data = data[:dl] + self.ReadBinary()
|
||||
return data
|
||||
except:
|
||||
pass
|
||||
return ''
|
||||
|
||||
def ReadUntilEOS(self,eos="\n",quota=0):
|
||||
"""
|
||||
ReadUntilEOS(eosString=\"\\n\",timeout=1000)
|
||||
Reads data until the given eos string was received (default is
|
||||
the linefeed character (0x0a) or the internal timeout
|
||||
(default 1000ms) was reached.
|
||||
ReadUntilEOS returns the result as the following tuple:
|
||||
['received string',state,readedBytes]
|
||||
If a timeout occurred, state is 0, otherwise 1
|
||||
"""
|
||||
return self.device.ReadUntilEOS("",0,eos,self.timeout,quota)
|
||||
|
||||
def Readv(self,length):
|
||||
"""
|
||||
Try to read the given count of data. Readv blocks until all data
|
||||
was readed successfully or the internal timeout, set with the
|
||||
class member function SetTimeout(timeout), was reached.
|
||||
Returns the readed data.
|
||||
"""
|
||||
buf = "\x00"*length
|
||||
rd = self.device.Readv(buf,length,self.timeout)
|
||||
return buf[0:rd]
|
||||
|
||||
def ResetBus(self):
|
||||
"""
|
||||
If the underlaying interface needs some special reset operations
|
||||
(for instance the GPIB distinguish between a normal device reset
|
||||
and a special bus reset), you can put some code here)
|
||||
"""
|
||||
pass
|
||||
|
||||
def SetTimeout(self,timeout):
|
||||
"""
|
||||
Set the internal timeout value in milliseconds for all blocked
|
||||
operations like ReadUntilEOS, Readv and Writev.
|
||||
"""
|
||||
self.timeout = timeout
|
||||
|
||||
def Write(self,string):
|
||||
"""
|
||||
Writes the given string to the device and returns immediately.
|
||||
Write returns the number of data bytes successfully written or a
|
||||
negativ number if an error occured. For some circumstances, not
|
||||
the complete string was written.
|
||||
So you have to verify the return value to check this out.
|
||||
"""
|
||||
return self.device.Write(string,len(string))
|
||||
|
||||
def Writev(self,string):
|
||||
"""
|
||||
Writes the given string to the device. The function blocks until
|
||||
the complete string was written or the internal timeout, set with
|
||||
SetTimeout(timeout), was reached.
|
||||
Writev returns the number of data successfully written or a
|
||||
negativ value, if an errors occurred.
|
||||
"""
|
||||
return self.device.Writev(string,len(string),self.timeout)
|
||||
|
||||
class SerialPort(IOBase):
|
||||
def __init__(self):
|
||||
IOBase.__init__(self)
|
||||
|
||||
def __del__(self):
|
||||
self.Close()
|
||||
|
||||
def ChangeLineState(self,lineState):
|
||||
"""
|
||||
Change (toggle) the state of each the lines given in the
|
||||
linestate parameter. Possible values are DTR and/or RTS.
|
||||
For example to toggle the RTS line only:
|
||||
dev.ChangeLineState(RTS)
|
||||
"""
|
||||
self.device.ChangeLineState(lineState)
|
||||
|
||||
def ClrLineState(self,lineState):
|
||||
"""
|
||||
Clear the lines given in the linestate parameter. Possible
|
||||
values are DTR and/or RTS. For example to clear only
|
||||
the RTS line:
|
||||
dev.ClrLineState(RTS)
|
||||
"""
|
||||
self.device.ClrLineState(lineState)
|
||||
|
||||
def GetAvailableBytes(self):
|
||||
"""
|
||||
Returns the available bytes in the input queue of the serial
|
||||
driver.
|
||||
"""
|
||||
n = wxctb.new_intp()
|
||||
wxctb.intp_assign(n, 0)
|
||||
self.device.Ioctl(wxctb.CTB_SER_GETINQUE,n)
|
||||
return wxctb.intp_value(n)
|
||||
|
||||
def GetCommErrors(self):
|
||||
"""
|
||||
Get the internal communication errors like breaks, framing,
|
||||
parity or overrun errors.
|
||||
Returns the count of each error as a tuple like this:
|
||||
(b,f,o,p) = dev.GetCommErrors()
|
||||
b: breaks, f: framing errors, o: overruns, p: parity errors
|
||||
"""
|
||||
einfo = wxctb.SerialPort_EINFO()
|
||||
self.device.Ioctl(wxctb.CTB_SER_GETEINFO,einfo)
|
||||
return einfo.brk,einfo.frame,einfo.overrun,einfo.parity
|
||||
|
||||
def GetLineState(self):
|
||||
"""
|
||||
Returns the current linestates of the CTS, DCD, DSR and RING
|
||||
signal line as an integer value with the appropriate bits or
|
||||
-1 on error.
|
||||
For example:
|
||||
lines = dev.GetLineState()
|
||||
if lines & CTS:
|
||||
print \"CTS is on\"
|
||||
"""
|
||||
return self.device.GetLineState()
|
||||
|
||||
def Open(self,devname,baudrate,protocol='8N1',handshake='no_handshake'):
|
||||
"""
|
||||
Open the device devname with the given baudrate, the protocol
|
||||
like '8N1' (default) and the use of the handshake [no_handshake
|
||||
(default), rtscts or xonxoff]
|
||||
For example:
|
||||
At Linux:
|
||||
dev = SerialPort()
|
||||
dev.Open(\"/dev/ttyS0\",115200)
|
||||
or with a datalen of 7 bits, even parity, 2 stopbits and rts/cts
|
||||
handshake:
|
||||
dev.Open(\"/dev/ttyS0\",115200,'7E2',True)
|
||||
At Windows:
|
||||
dev = SerialPort()
|
||||
dev.Open(\"COM1\",115200)
|
||||
dev.Open(\"COM1\",115200,'7E2',True)
|
||||
Returns the handle on success or a negativ value on failure.
|
||||
"""
|
||||
# the following parity values are valid:
|
||||
# N:None, O:Odd, E:Even, M:Mark, S:Space
|
||||
parity = {'N':0,'O':1,'E':2,'M':3,'S':4}
|
||||
# the regular expression ensures a valid value for the datalen
|
||||
# (5...8 bit) and the count of stopbits (1,2)
|
||||
reg=re.compile(r"(?P<w>[8765])"r"(?P<p>[NOEMS])"r"(?P<s>[12])")
|
||||
self.device = wxctb.SerialPort()
|
||||
dcs = wxctb.SerialPort_DCS()
|
||||
dcs.baud = baudrate
|
||||
res = reg.search(protocol)
|
||||
# handle the given protocol
|
||||
if res:
|
||||
dcs.wordlen = int(res.group('w'))
|
||||
dcs.stopbits = int(res.group('s'))
|
||||
dcs.parity = parity[res.group('p')]
|
||||
# valid handshake are no one, rts/cts or xon/xoff
|
||||
if handshake == 'rtscts':
|
||||
dcs.rtscts = True
|
||||
elif handshake == 'xonxoff':
|
||||
dcs.xonxoff = True
|
||||
|
||||
return self.device.Open(devname,dcs)
|
||||
|
||||
def Reset(self):
|
||||
"""
|
||||
Send a break for 0.25s.
|
||||
"""
|
||||
self.device.SendBreak(0)
|
||||
|
||||
def SetBaudrate(self,baudrate):
|
||||
"""
|
||||
Set the baudrate for the device.
|
||||
"""
|
||||
self.device.SetBaudrate(baudrate)
|
||||
|
||||
def SetLineState(self,lineState):
|
||||
"""
|
||||
Set the lines given in the linestate parameter. Possible
|
||||
values are DTR and/or RTS. For example to set both:
|
||||
dev.SetLineState( DTR | RTS)
|
||||
"""
|
||||
self.device.SetLineState(lineState)
|
||||
|
||||
def SetParityBit(self,parity):
|
||||
"""
|
||||
Set the parity bit explicitly to 0 or 1. Use this function, if
|
||||
you would like to simulate a 9 bit wordlen at what the ninth bit
|
||||
was represented by the parity bit value. For example:
|
||||
dev.SetParityBit( 0 )
|
||||
dev.Write('some data sent with parity 0')
|
||||
dev.SetParityBit( 1 )
|
||||
dev.Write('another sequence with parity 1')
|
||||
"""
|
||||
return self.device.SetParityBit( parity )
|
||||
|
||||
class GpibDevice(IOBase):
|
||||
"""
|
||||
GPIB class
|
||||
"""
|
||||
def __init__(self):
|
||||
IOBase.__init__(self)
|
||||
|
||||
def __del__(self):
|
||||
self.Close()
|
||||
|
||||
def FindListeners(self,board = 0):
|
||||
"""
|
||||
Returns the address of the connected devices as a list.
|
||||
If no device is listening, the list is empty. If an error
|
||||
occurs an IOError exception raised. For example:
|
||||
g = GPIB()
|
||||
listeners = g.FindListeners()
|
||||
"""
|
||||
listeners = wxctb.GPIB_x_FindListeners(board)
|
||||
if listeners < 0:
|
||||
raise IOError("GPIB board error")
|
||||
result = []
|
||||
for i in range(1,31):
|
||||
if listeners & (1 << i):
|
||||
result.append(i)
|
||||
return result
|
||||
|
||||
def GetEosChar(self):
|
||||
"""
|
||||
Get the internal EOS termination character (see SetEosChar).
|
||||
For example:
|
||||
g = GPIB()
|
||||
g.Open(\"gpib1\",1)
|
||||
eos = g.GetEosChar()
|
||||
"""
|
||||
eos = wxctb.new_intp()
|
||||
wxctb.intp_assign(eos, 0)
|
||||
self.device.Ioctl(wxctb.CTB_GPIB_GET_EOS_CHAR,eos)
|
||||
return wxctb.intp_value(eos)
|
||||
|
||||
def GetEosMode(self):
|
||||
"""
|
||||
Get the internal EOS mode (see SetEosMode).
|
||||
For example:
|
||||
g = GPIB()
|
||||
g.Open(\"gpib1\",1)
|
||||
eos = g.GetEosMode()
|
||||
"""
|
||||
mode = wxctb.new_intp()
|
||||
wxctb.intp_assign(mode, 0)
|
||||
self.device.Ioctl(wxctb.CTB_GPIB_GET_EOS_MODE,mode)
|
||||
return wxctb.intp_value(mode)
|
||||
|
||||
def GetError(self):
|
||||
errorString = " "*256
|
||||
self.device.GetError(errorString,256)
|
||||
return errorString
|
||||
|
||||
def GetSTB(self):
|
||||
"""
|
||||
Returns the value of the internal GPIB status byte register.
|
||||
"""
|
||||
stb = wxctb.new_intp()
|
||||
wxctb.intp_assign(stb, 0)
|
||||
self.device.Ioctl(wxctb.CTB_GPIB_GETRSP,stb)
|
||||
return wxctb.intp_value(stb)
|
||||
|
||||
# This is only for internal usage!!!
|
||||
def Ibrd(self,length):
|
||||
buf = "\x00"*length
|
||||
state = self.device.Ibrd(buf,length)
|
||||
return state,buf
|
||||
|
||||
# This is only for internal usage!!!
|
||||
def Ibwrt(self,string):
|
||||
return self.device.Ibwrt(string,len(string))
|
||||
|
||||
def Open(self,devname,adr,eosChar=10,eosMode=0x08|0x04):
|
||||
"""
|
||||
Open(gpibdevice,address,eosChar,eosMode)
|
||||
Opens a connected device at the GPIB bus. gpibdevice means the
|
||||
controller, (mostly \"gpib1\"), address the address of the desired
|
||||
device in the range 1...31. The eosChar defines the EOS character
|
||||
(default is linefeed), eosMode may be a combination of bits ORed
|
||||
together. The following bits can be used:
|
||||
0x04: Terminate read when EOS is detected.
|
||||
0x08: Set EOI (End or identify line) with EOS on write function
|
||||
0x10: Compare all 8 bits of EOS byte rather than low 7 bits
|
||||
(all read and write functions). Default is 0x12
|
||||
For example:
|
||||
dev = GPIB()
|
||||
dev.Open(\"gpib1\",17)
|
||||
Opens the device with the address 17, linefeed as EOS (default)
|
||||
and eos mode with 0x04 and 0x08.
|
||||
Open returns >= 0 or a negativ value, if something going wrong.
|
||||
"""
|
||||
self.device = wxctb.GpibDevice()
|
||||
dcs = wxctb.Gpib_DCS()
|
||||
dcs.m_address1 = adr
|
||||
dcs.m_eosChar = eosChar
|
||||
dcs.m_eosMode = eosMode
|
||||
result = self.device.Open(devname,dcs)
|
||||
return result
|
||||
|
||||
def Reset(self):
|
||||
"""
|
||||
Resets the connected device. In the GPIB definition, the device
|
||||
should be reset to it's initial state, so you can restart a
|
||||
formely lost communication.
|
||||
"""
|
||||
self.device.Ioctl(wxctb.CTB_RESET,None)
|
||||
|
||||
def ResetBus(self):
|
||||
"""
|
||||
The command asserts the GPIB interface clear (IFC) line for
|
||||
ast least 100us if the GPIB board is the system controller.
|
||||
This initializes the GPIB and makes the interface CIC and
|
||||
active controller with ATN asserted.
|
||||
Note! The IFC signal resets only the GPIB interface functions
|
||||
of the bus devices and not the internal device functions.
|
||||
For a device reset you should use the Reset() command above.
|
||||
"""
|
||||
self.device.Ioctl(wxctb.CTB_GPIB_RESET_BUS,None)
|
||||
|
||||
def SetEosChar(self,eos):
|
||||
"""
|
||||
Configure the end-of-string (EOS) termination character.
|
||||
Note! Defining an EOS byte does not cause the driver to
|
||||
automatically send that byte at the end of write I/O
|
||||
operations. The application is responsible for placing the
|
||||
EOS byte at the end of the data strings that it defines.
|
||||
(National Instruments NI-488.2M Function Reference Manual)
|
||||
For example:
|
||||
g = GPIB()
|
||||
g.Open(\"gpib1\",1)
|
||||
eos = g.GetEosChar(0x10)
|
||||
"""
|
||||
intp = wxctb.new_intp()
|
||||
wxctb.intp_assign(intp, eos)
|
||||
return self.device.Ioctl(wxctb.CTB_GPIB_SET_EOS_CHAR,intp)
|
||||
|
||||
def SetEosMode(self,mode):
|
||||
"""
|
||||
Set the EOS mode (handling).m_eosMode may be a combination
|
||||
of bits ORed together. The following bits can be used:
|
||||
0x04: Terminate read when EOS is detected.
|
||||
0x08: Set EOI (End or identify line) with EOS on write function
|
||||
0x10: Compare all 8 bits of EOS byte rather than low 7 bits
|
||||
(all read and write functions). For example:
|
||||
g = GPIB()
|
||||
g.Open(\"gpib1\",1)
|
||||
eos = g.GetEosMode(0x04 | 0x08)
|
||||
"""
|
||||
intp = wxctb.new_intp()
|
||||
wxctb.intp_assign(intp, mode)
|
||||
return self.device.Ioctl(wxctb.CTB_GPIB_SET_EOS_MODE,intp)
|
||||
|
||||
def GetKey():
|
||||
"""
|
||||
Returns the current pressed key or '\0', if no key is pressed.
|
||||
You can simply create a query loop with:
|
||||
while GetKey() == '\0':
|
||||
... make some stuff ...
|
||||
|
||||
"""
|
||||
return wxctb.GetKey()
|
||||
|
||||
def GetVersion():
|
||||
"""
|
||||
Returns the version of the ctb python module. The numbering
|
||||
has the following format: x.y.z
|
||||
x.y means the version of the underlaying ctb lib, z the version
|
||||
of the python port.
|
||||
"""
|
||||
return "0.16"
|
||||
@@ -0,0 +1,264 @@
|
||||
# This file was automatically generated by SWIG (http://www.swig.org).
|
||||
# Version 1.3.40
|
||||
#
|
||||
# Do not make changes to this file unless you know what you are doing--modify
|
||||
# the SWIG interface file instead.
|
||||
|
||||
from sys import version_info
|
||||
if version_info >= (2,6,0):
|
||||
def swig_import_helper():
|
||||
from os.path import dirname
|
||||
import imp
|
||||
fp = None
|
||||
try:
|
||||
fp, pathname, description = imp.find_module('_wxctb', [dirname(__file__)])
|
||||
except ImportError:
|
||||
import _wxctb
|
||||
return _wxctb
|
||||
if fp is not None:
|
||||
try:
|
||||
_mod = imp.load_module('_wxctb', fp, pathname, description)
|
||||
finally:
|
||||
fp.close()
|
||||
return _mod
|
||||
_wxctb = swig_import_helper()
|
||||
del swig_import_helper
|
||||
else:
|
||||
import _wxctb
|
||||
del version_info
|
||||
try:
|
||||
_swig_property = property
|
||||
except NameError:
|
||||
pass # Python < 2.2 doesn't have 'property'.
|
||||
def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
|
||||
if (name == "thisown"): return self.this.own(value)
|
||||
if (name == "this"):
|
||||
if type(value).__name__ == 'SwigPyObject':
|
||||
self.__dict__[name] = value
|
||||
return
|
||||
method = class_type.__swig_setmethods__.get(name,None)
|
||||
if method: return method(self,value)
|
||||
if (not static) or hasattr(self,name):
|
||||
self.__dict__[name] = value
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
|
||||
def _swig_setattr(self,class_type,name,value):
|
||||
return _swig_setattr_nondynamic(self,class_type,name,value,0)
|
||||
|
||||
def _swig_getattr(self,class_type,name):
|
||||
if (name == "thisown"): return self.this.own()
|
||||
method = class_type.__swig_getmethods__.get(name,None)
|
||||
if method: return method(self)
|
||||
raise AttributeError(name)
|
||||
|
||||
def _swig_repr(self):
|
||||
try: strthis = "proxy of " + self.this.__repr__()
|
||||
except: strthis = ""
|
||||
return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
|
||||
|
||||
try:
|
||||
_object = object
|
||||
_newclass = 1
|
||||
except AttributeError:
|
||||
class _object : pass
|
||||
_newclass = 0
|
||||
|
||||
|
||||
def _swig_setattr_nondynamic_method(set):
|
||||
def set_attr(self,name,value):
|
||||
if (name == "thisown"): return self.this.own(value)
|
||||
if hasattr(self,name) or (name == "this"):
|
||||
set(self,name,value)
|
||||
else:
|
||||
raise AttributeError("You cannot add attributes to %s" % self)
|
||||
return set_attr
|
||||
|
||||
|
||||
|
||||
def new_intp():
|
||||
return _wxctb.new_intp()
|
||||
new_intp = _wxctb.new_intp
|
||||
|
||||
def copy_intp(*args, **kwargs):
|
||||
return _wxctb.copy_intp(*args, **kwargs)
|
||||
copy_intp = _wxctb.copy_intp
|
||||
|
||||
def delete_intp(*args, **kwargs):
|
||||
return _wxctb.delete_intp(*args, **kwargs)
|
||||
delete_intp = _wxctb.delete_intp
|
||||
|
||||
def intp_assign(*args, **kwargs):
|
||||
return _wxctb.intp_assign(*args, **kwargs)
|
||||
intp_assign = _wxctb.intp_assign
|
||||
|
||||
def intp_value(*args, **kwargs):
|
||||
return _wxctb.intp_value(*args, **kwargs)
|
||||
intp_value = _wxctb.intp_value
|
||||
class timer_control(object):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
|
||||
__repr__ = _swig_repr
|
||||
usecs = _swig_property(_wxctb.timer_control_usecs_get, _wxctb.timer_control_usecs_set)
|
||||
exitflag = _swig_property(_wxctb.timer_control_exitflag_get, _wxctb.timer_control_exitflag_set)
|
||||
exitfnc = _swig_property(_wxctb.timer_control_exitfnc_get, _wxctb.timer_control_exitfnc_set)
|
||||
timer_control_swigregister = _wxctb.timer_control_swigregister
|
||||
timer_control_swigregister(timer_control)
|
||||
|
||||
class Timer(object):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
__repr__ = _swig_repr
|
||||
def __init__(self, *args, **kwargs):
|
||||
this = _wxctb.new_Timer(*args, **kwargs)
|
||||
try: self.this.append(this)
|
||||
except: self.this = this
|
||||
__swig_destroy__ = _wxctb.delete_Timer
|
||||
__del__ = lambda self : None;
|
||||
def start(self): return _wxctb.Timer_start(self)
|
||||
def stop(self): return _wxctb.Timer_stop(self)
|
||||
Timer_swigregister = _wxctb.Timer_swigregister
|
||||
Timer_swigregister(Timer)
|
||||
|
||||
|
||||
def sleepms(*args, **kwargs):
|
||||
return _wxctb.sleepms(*args, **kwargs)
|
||||
sleepms = _wxctb.sleepms
|
||||
CTB_RESET = _wxctb.CTB_RESET
|
||||
class IOBase(object):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
|
||||
__repr__ = _swig_repr
|
||||
__swig_destroy__ = _wxctb.delete_IOBase
|
||||
__del__ = lambda self : None;
|
||||
def ClassName(self): return _wxctb.IOBase_ClassName(self)
|
||||
def Close(self): return _wxctb.IOBase_Close(self)
|
||||
def Ioctl(self, *args, **kwargs): return _wxctb.IOBase_Ioctl(self, *args, **kwargs)
|
||||
def IsOpen(self): return _wxctb.IOBase_IsOpen(self)
|
||||
def Open(self, *args, **kwargs): return _wxctb.IOBase_Open(self, *args, **kwargs)
|
||||
def PutBack(self, *args, **kwargs): return _wxctb.IOBase_PutBack(self, *args, **kwargs)
|
||||
def Read(self, *args, **kwargs): return _wxctb.IOBase_Read(self, *args, **kwargs)
|
||||
def ReadUntilEOS(self, *args, **kwargs): return _wxctb.IOBase_ReadUntilEOS(self, *args, **kwargs)
|
||||
def Readv(self, *args, **kwargs): return _wxctb.IOBase_Readv(self, *args, **kwargs)
|
||||
def Write(self, *args, **kwargs): return _wxctb.IOBase_Write(self, *args, **kwargs)
|
||||
def Writev(self, *args, **kwargs): return _wxctb.IOBase_Writev(self, *args, **kwargs)
|
||||
IOBase_swigregister = _wxctb.IOBase_swigregister
|
||||
IOBase_swigregister(IOBase)
|
||||
|
||||
ParityNone = _wxctb.ParityNone
|
||||
ParityOdd = _wxctb.ParityOdd
|
||||
ParityEven = _wxctb.ParityEven
|
||||
ParityMark = _wxctb.ParityMark
|
||||
ParitySpace = _wxctb.ParitySpace
|
||||
LinestateDcd = _wxctb.LinestateDcd
|
||||
LinestateCts = _wxctb.LinestateCts
|
||||
LinestateDsr = _wxctb.LinestateDsr
|
||||
LinestateDtr = _wxctb.LinestateDtr
|
||||
LinestateRing = _wxctb.LinestateRing
|
||||
LinestateRts = _wxctb.LinestateRts
|
||||
LinestateNull = _wxctb.LinestateNull
|
||||
class SerialPort_DCS(object):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
__repr__ = _swig_repr
|
||||
baud = _swig_property(_wxctb.SerialPort_DCS_baud_get, _wxctb.SerialPort_DCS_baud_set)
|
||||
parity = _swig_property(_wxctb.SerialPort_DCS_parity_get, _wxctb.SerialPort_DCS_parity_set)
|
||||
wordlen = _swig_property(_wxctb.SerialPort_DCS_wordlen_get, _wxctb.SerialPort_DCS_wordlen_set)
|
||||
stopbits = _swig_property(_wxctb.SerialPort_DCS_stopbits_get, _wxctb.SerialPort_DCS_stopbits_set)
|
||||
rtscts = _swig_property(_wxctb.SerialPort_DCS_rtscts_get, _wxctb.SerialPort_DCS_rtscts_set)
|
||||
xonxoff = _swig_property(_wxctb.SerialPort_DCS_xonxoff_get, _wxctb.SerialPort_DCS_xonxoff_set)
|
||||
buf = _swig_property(_wxctb.SerialPort_DCS_buf_get, _wxctb.SerialPort_DCS_buf_set)
|
||||
def __init__(self):
|
||||
this = _wxctb.new_SerialPort_DCS()
|
||||
try: self.this.append(this)
|
||||
except: self.this = this
|
||||
__swig_destroy__ = _wxctb.delete_SerialPort_DCS
|
||||
__del__ = lambda self : None;
|
||||
def GetSettings(self): return _wxctb.SerialPort_DCS_GetSettings(self)
|
||||
SerialPort_DCS_swigregister = _wxctb.SerialPort_DCS_swigregister
|
||||
SerialPort_DCS_swigregister(SerialPort_DCS)
|
||||
|
||||
class SerialPort_EINFO(object):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
__repr__ = _swig_repr
|
||||
brk = _swig_property(_wxctb.SerialPort_EINFO_brk_get, _wxctb.SerialPort_EINFO_brk_set)
|
||||
frame = _swig_property(_wxctb.SerialPort_EINFO_frame_get, _wxctb.SerialPort_EINFO_frame_set)
|
||||
overrun = _swig_property(_wxctb.SerialPort_EINFO_overrun_get, _wxctb.SerialPort_EINFO_overrun_set)
|
||||
parity = _swig_property(_wxctb.SerialPort_EINFO_parity_get, _wxctb.SerialPort_EINFO_parity_set)
|
||||
def __init__(self):
|
||||
this = _wxctb.new_SerialPort_EINFO()
|
||||
try: self.this.append(this)
|
||||
except: self.this = this
|
||||
__swig_destroy__ = _wxctb.delete_SerialPort_EINFO
|
||||
__del__ = lambda self : None;
|
||||
SerialPort_EINFO_swigregister = _wxctb.SerialPort_EINFO_swigregister
|
||||
SerialPort_EINFO_swigregister(SerialPort_EINFO)
|
||||
|
||||
CTB_SER_GETEINFO = _wxctb.CTB_SER_GETEINFO
|
||||
CTB_SER_GETBRK = _wxctb.CTB_SER_GETBRK
|
||||
CTB_SER_GETFRM = _wxctb.CTB_SER_GETFRM
|
||||
CTB_SER_GETOVR = _wxctb.CTB_SER_GETOVR
|
||||
CTB_SER_GETPAR = _wxctb.CTB_SER_GETPAR
|
||||
CTB_SER_GETINQUE = _wxctb.CTB_SER_GETINQUE
|
||||
CTB_SER_SETPAR = _wxctb.CTB_SER_SETPAR
|
||||
class SerialPort_x(IOBase):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
|
||||
__repr__ = _swig_repr
|
||||
__swig_destroy__ = _wxctb.delete_SerialPort_x
|
||||
__del__ = lambda self : None;
|
||||
def ClassName(self): return _wxctb.SerialPort_x_ClassName(self)
|
||||
def ChangeLineState(self, *args, **kwargs): return _wxctb.SerialPort_x_ChangeLineState(self, *args, **kwargs)
|
||||
def ClrLineState(self, *args, **kwargs): return _wxctb.SerialPort_x_ClrLineState(self, *args, **kwargs)
|
||||
def GetLineState(self): return _wxctb.SerialPort_x_GetLineState(self)
|
||||
def GetSettingsAsString(self): return _wxctb.SerialPort_x_GetSettingsAsString(self)
|
||||
def Ioctl(self, *args, **kwargs): return _wxctb.SerialPort_x_Ioctl(self, *args, **kwargs)
|
||||
def SendBreak(self, *args, **kwargs): return _wxctb.SerialPort_x_SendBreak(self, *args, **kwargs)
|
||||
def SetBaudrate(self, *args, **kwargs): return _wxctb.SerialPort_x_SetBaudrate(self, *args, **kwargs)
|
||||
def SetLineState(self, *args, **kwargs): return _wxctb.SerialPort_x_SetLineState(self, *args, **kwargs)
|
||||
def SetParityBit(self, *args, **kwargs): return _wxctb.SerialPort_x_SetParityBit(self, *args, **kwargs)
|
||||
IsStandardRate = staticmethod(_wxctb.SerialPort_x_IsStandardRate)
|
||||
SerialPort_x_swigregister = _wxctb.SerialPort_x_swigregister
|
||||
SerialPort_x_swigregister(SerialPort_x)
|
||||
|
||||
def SerialPort_x_IsStandardRate(*args, **kwargs):
|
||||
return _wxctb.SerialPort_x_IsStandardRate(*args, **kwargs)
|
||||
SerialPort_x_IsStandardRate = _wxctb.SerialPort_x_IsStandardRate
|
||||
|
||||
COM1 = "/dev/ttyS0"
|
||||
COM2 = "/dev/ttyS1"
|
||||
COM3 = "/dev/ttyS2"
|
||||
COM4 = "/dev/ttyS3"
|
||||
COM5 = "/dev/ttyS4"
|
||||
COM6 = "/dev/ttyS5"
|
||||
COM7 = "/dev/ttyS6"
|
||||
COM8 = "/dev/ttyS7"
|
||||
COM9 = "/dev/ttyS8"
|
||||
|
||||
class SerialPort(SerialPort_x):
|
||||
thisown = _swig_property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc='The membership flag')
|
||||
__repr__ = _swig_repr
|
||||
def __init__(self):
|
||||
this = _wxctb.new_SerialPort()
|
||||
try: self.this.append(this)
|
||||
except: self.this = this
|
||||
__swig_destroy__ = _wxctb.delete_SerialPort
|
||||
__del__ = lambda self : None;
|
||||
def ChangeLineState(self, *args, **kwargs): return _wxctb.SerialPort_ChangeLineState(self, *args, **kwargs)
|
||||
def ClrLineState(self, *args, **kwargs): return _wxctb.SerialPort_ClrLineState(self, *args, **kwargs)
|
||||
def GetLineState(self): return _wxctb.SerialPort_GetLineState(self)
|
||||
def Ioctl(self, *args, **kwargs): return _wxctb.SerialPort_Ioctl(self, *args, **kwargs)
|
||||
def IsOpen(self): return _wxctb.SerialPort_IsOpen(self)
|
||||
def Read(self, *args, **kwargs): return _wxctb.SerialPort_Read(self, *args, **kwargs)
|
||||
def SendBreak(self, *args, **kwargs): return _wxctb.SerialPort_SendBreak(self, *args, **kwargs)
|
||||
def SetBaudrate(self, *args, **kwargs): return _wxctb.SerialPort_SetBaudrate(self, *args, **kwargs)
|
||||
def SetLineState(self, *args, **kwargs): return _wxctb.SerialPort_SetLineState(self, *args, **kwargs)
|
||||
def SetParityBit(self, *args, **kwargs): return _wxctb.SerialPort_SetParityBit(self, *args, **kwargs)
|
||||
def Write(self, *args, **kwargs): return _wxctb.SerialPort_Write(self, *args, **kwargs)
|
||||
SerialPort_swigregister = _wxctb.SerialPort_swigregister
|
||||
SerialPort_swigregister(SerialPort)
|
||||
|
||||
|
||||
def GetKey():
|
||||
return _wxctb.GetKey()
|
||||
GetKey = _wxctb.GetKey
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import getopt, time, sys
|
||||
|
||||
sys.path.insert( 0, r'/home/jb/project/libctb-0.16/python/module/linux')
|
||||
|
||||
import ctb
|
||||
|
||||
def main():
|
||||
|
||||
baudrate = 19200
|
||||
|
||||
devname = ""
|
||||
|
||||
protocol = '8N1'
|
||||
|
||||
try:
|
||||
opt,arg = getopt.getopt(sys.argv[1:],
|
||||
'b:d:p:',
|
||||
['baudrate=',
|
||||
'device=',
|
||||
'protocol='
|
||||
])
|
||||
|
||||
except getopt.GetoptError:
|
||||
print "usage: parity.py [options]\n"\
|
||||
"\t-b baudrate\n"\
|
||||
"\t--baudrate=baudrate"\
|
||||
"\t-d device\n"\
|
||||
"\t--device=serial device name like /dev/ttyS0 or COM1\n"\
|
||||
"\t-h\n"\
|
||||
"\t--help print this\n"\
|
||||
"\n"
|
||||
sys.exit(0)
|
||||
|
||||
for o,a in opt:
|
||||
|
||||
if o in ("-b","--baudrate"):
|
||||
|
||||
baudrate = int(a)
|
||||
|
||||
if o in ("-d","--device"):
|
||||
|
||||
devname = a
|
||||
|
||||
if o in ("-p","--protocol"):
|
||||
|
||||
protocol = a
|
||||
|
||||
|
||||
print "Using ctb version " + ctb.GetVersion()
|
||||
|
||||
dev = ctb.SerialPort()
|
||||
|
||||
if dev.Open( devname, baudrate, protocol ) < 0:
|
||||
|
||||
print "Cannot open " + devname + "\n"
|
||||
|
||||
# send the following string with a always set parity bit
|
||||
dev.SetParityBit( 1 )
|
||||
|
||||
dev.Writev( "Hello World" )
|
||||
|
||||
# send the following string with a always cleared parity bit
|
||||
dev.SetParityBit( 0 )
|
||||
|
||||
dev.Writev( "Hello World" )
|
||||
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import getopt, time, sys
|
||||
|
||||
sys.path.insert( 0, r'/home/jb/project/libctb-0.16/python/module/linux')
|
||||
|
||||
import ctb
|
||||
|
||||
def DataBlock():
|
||||
data = ''
|
||||
for c in range( 0, 256):
|
||||
data += '%c' % c
|
||||
|
||||
return data
|
||||
|
||||
def main():
|
||||
|
||||
baudrate = 19200
|
||||
|
||||
devname = ""
|
||||
|
||||
try:
|
||||
opt,arg = getopt.getopt(sys.argv[1:],
|
||||
'b:d:',
|
||||
['baudrate=',
|
||||
'device='
|
||||
])
|
||||
|
||||
except getopt.GetoptError:
|
||||
print "usage: protocol.py [options]\n"\
|
||||
"\t-b baudrate\n"\
|
||||
"\t--baudrate=baudrate"\
|
||||
"\t-d device\n"\
|
||||
"\t--device=serial device name like /dev/ttyS0 or COM1\n"\
|
||||
"\t-h\n"\
|
||||
"\t--help print this\n"\
|
||||
"\n"
|
||||
sys.exit(0)
|
||||
|
||||
for o,a in opt:
|
||||
|
||||
if o in ("-b","--baudrate"):
|
||||
|
||||
baudrate = int(a)
|
||||
|
||||
if o in ("-d","--device"):
|
||||
|
||||
devname = a
|
||||
|
||||
print "Using ctb version " + ctb.GetVersion()
|
||||
|
||||
dev = ctb.SerialPort()
|
||||
|
||||
protocols = [
|
||||
'8N1','8O1','8E1','8S1','8M1'
|
||||
]
|
||||
|
||||
dev.SetTimeout( 1000 )
|
||||
|
||||
for protocol in protocols:
|
||||
|
||||
if dev.Open( devname, baudrate, protocol ) < 0:
|
||||
|
||||
print "Cannot open " + devname + "\n"
|
||||
|
||||
sys.exit( 1 )
|
||||
|
||||
else:
|
||||
|
||||
print( "%i %s" % ( baudrate, protocol ) )
|
||||
|
||||
for i in range(0, 4 ):
|
||||
|
||||
dev.Writev( "\x33" )
|
||||
|
||||
time.sleep( 0.0006 )
|
||||
|
||||
dev.Writev( "\x31" )
|
||||
|
||||
time.sleep( 0.0006 )
|
||||
|
||||
time.sleep( 0.5 )
|
||||
|
||||
dev.Close()
|
||||
|
||||
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import getopt, time, sys
|
||||
|
||||
sys.path.insert( 0, r'/home/jb/project/libctb-0.16/python/module/linux')
|
||||
|
||||
import ctb
|
||||
|
||||
def main():
|
||||
|
||||
devname = ""
|
||||
|
||||
try:
|
||||
opt,arg = getopt.getopt(sys.argv[1:],
|
||||
'd:',
|
||||
['device='
|
||||
])
|
||||
|
||||
except getopt.GetoptError:
|
||||
print "usage: parity.py [options]\n"\
|
||||
"\t-d device\n"\
|
||||
"\t--device=serial device name like /dev/ttyS0 or COM1\n"\
|
||||
"\t-h\n"\
|
||||
"\t--help print this\n"\
|
||||
"\n"
|
||||
sys.exit(0)
|
||||
|
||||
for o,a in opt:
|
||||
|
||||
if o in ("-d","--device"):
|
||||
|
||||
devname = a
|
||||
|
||||
print "Using ctb version " + ctb.GetVersion()
|
||||
|
||||
dev = ctb.SerialPort()
|
||||
|
||||
if dev.Open( devname, 38400 ) < 0:
|
||||
|
||||
print "Cannot open " + devname + "\n"
|
||||
|
||||
dev.SetLineState( ctb.DTR )
|
||||
|
||||
dev.ClrLineState( ctb.RTS )
|
||||
|
||||
for i in range( 0, 100 ) :
|
||||
|
||||
time.sleep( 0.01 )
|
||||
|
||||
dev.ChangeLineState( ctb.DTR | ctb.RTS )
|
||||
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,353 @@
|
||||
|
||||
<!doctype html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module ctb</title>
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>ctb</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/mnt/s/wxaddons/wxctb-0.9/SWIG/ctb.py">/mnt/s/wxaddons/wxctb-0.9/SWIG/ctb.py</a></font></td></tr></table>
|
||||
<p></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#fffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="re.html">re</a><br>
|
||||
</td><td width="25%" valign=top><a href="sys.html">sys</a><br>
|
||||
</td><td width="25%" valign=top><a href="wxctb.html">wxctb</a><br>
|
||||
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="ctb.html#wxIOBase">wxIOBase</a>
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="ctb.html#wxGPIB">wxGPIB</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="ctb.html#wxSerialPort">wxSerialPort</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="wxGPIB">class <strong>wxGPIB</strong></a>(<a href="ctb.html#wxIOBase">wxIOBase</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt><a href="#wxGPIB">wxGPIB</a> class<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="wxGPIB-GetError"><strong>GetError</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-GetSTB"><strong>GetSTB</strong></a>(self)</dt><dd><tt>Returns the value of the internal GPIB status byte register.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Ibrd"><strong>Ibrd</strong></a>(self, length)</dt><dd><tt># This is only for internal usage!!!</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Ibwrt"><strong>Ibwrt</strong></a>(self, string)</dt><dd><tt># This is only for internal usage!!!</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Open"><strong>Open</strong></a>(self, devname, adr)</dt><dd><tt><a href="#wxGPIB-Open">Open</a>(gpibdevice,address)<br>
|
||||
Opens a connected device at the GPIB bus. gpibdevice means the<br>
|
||||
controller, (mostly "gpib1"), address the address of the desired<br>
|
||||
device in the range 1...31. For example:<br>
|
||||
dev = <a href="#wxGPIB">wxGPIB</a>()<br>
|
||||
dev.<a href="#wxGPIB-Open">Open</a>("gpib1",17)<br>
|
||||
Opens the device with the address 17.<br>
|
||||
Open returns >= 0 or a negativ value, if something going wrong.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Reset"><strong>Reset</strong></a>(self)</dt><dd><tt>Resets the connected device. In the GPIB definition, the device<br>
|
||||
should be reset to it's initial state, so you can restart a<br>
|
||||
formely lost communication.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-ResetBus"><strong>ResetBus</strong></a>(self)</dt><dd><tt>The command asserts the GPIB interface clear (IFC) line for<br>
|
||||
ast least 100us if the GPIB board is the system controller.<br>
|
||||
This initializes the GPIB and makes the interface CIC and<br>
|
||||
active controller with ATN asserted.<br>
|
||||
Note! The IFC signal resets only the GPIB interface functions<br>
|
||||
of the bus devices and not the internal device functions.<br>
|
||||
For a device reset you should use the <a href="#wxGPIB-Reset">Reset</a>() command above.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-__del__"><strong>__del__</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-__init__"><strong>__init__</strong></a>(self)</dt></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="ctb.html#wxIOBase">wxIOBase</a>:<br>
|
||||
<dl><dt><a name="wxGPIB-Close"><strong>Close</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-GetTimeout"><strong>GetTimeout</strong></a>(self)</dt><dd><tt>Returns the internal timeout value in milliseconds</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Ioctl"><strong>Ioctl</strong></a>(self, cmd, arg)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-PutBack"><strong>PutBack</strong></a>(self, char)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Read"><strong>Read</strong></a>(self, length)</dt><dd><tt>Try to read the given count of data (length) and returns the<br>
|
||||
successfully readed number of data. The function never blocks.<br>
|
||||
For example:<br>
|
||||
readed = dev.<a href="#wxGPIB-Read">Read</a>(100)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-ReadBinary"><strong>ReadBinary</strong></a>(self, eos<font color="#909090">='<font color="#c040c0">\n</font>'</font>)</dt><dd><tt>Special SCPI command. Read the next data coded as a SCPI<br>
|
||||
binary format.<br>
|
||||
A binary data transfer will be startet by '#'. The next byte<br>
|
||||
tells the count of bytes for the binary length header,<br>
|
||||
following by the length bytes. After these the data begins.<br>
|
||||
For example:<br>
|
||||
#500004xxxx<br>
|
||||
The header length covers 5 Byte, the length of the binary<br>
|
||||
data is 4 (x means the binary data bytes)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-ReadUntilEOS"><strong>ReadUntilEOS</strong></a>(self, eos<font color="#909090">='<font color="#c040c0">\n</font>'</font>, quota<font color="#909090">=0</font>)</dt><dd><tt><a href="#wxGPIB-ReadUntilEOS">ReadUntilEOS</a>(eosString="\n",timeout=1000)<br>
|
||||
Reads data until the given eos string was received (default is<br>
|
||||
the linefeed character (0x0a) or the internal timeout<br>
|
||||
(default 1000ms) was reached.<br>
|
||||
ReadUntilEOS returns the result as the following tuple:<br>
|
||||
['received string',state,readedBytes]<br>
|
||||
If a timeout occurred, state is 0, otherwise 1</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Readv"><strong>Readv</strong></a>(self, length)</dt><dd><tt>Try to read the given count of data. Readv blocks until all data<br>
|
||||
was readed successfully or the internal timeout, set with the<br>
|
||||
class member function <a href="#wxGPIB-SetTimeout">SetTimeout</a>(timeout), was reached.<br>
|
||||
Returns the readed data.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-SetTimeout"><strong>SetTimeout</strong></a>(self, timeout)</dt><dd><tt>Set the internal timeout value in milliseconds for all blocked<br>
|
||||
operations like ReadUntilEOS, Readv and Writev.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Write"><strong>Write</strong></a>(self, string)</dt><dd><tt>Writes the given string to the device and returns immediately.<br>
|
||||
Write returns the number of data bytes successfully written or a<br>
|
||||
negativ number if an error occured. For some circumstances, not<br>
|
||||
the complete string was written.<br>
|
||||
So you have to verify the return value to check this out.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxGPIB-Writev"><strong>Writev</strong></a>(self, string)</dt><dd><tt>Writes the given string to the device. The function blocks until<br>
|
||||
the complete string was written or the internal timeout, set with<br>
|
||||
<a href="#wxGPIB-SetTimeout">SetTimeout</a>(timeout), was reached.<br>
|
||||
Writev returns the number of data successfully written or a<br>
|
||||
negativ value, if an errors occurred.</tt></dd></dl>
|
||||
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="wxIOBase">class <strong>wxIOBase</strong></a></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="wxIOBase-Close"><strong>Close</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-GetTimeout"><strong>GetTimeout</strong></a>(self)</dt><dd><tt>Returns the internal timeout value in milliseconds</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-Ioctl"><strong>Ioctl</strong></a>(self, cmd, arg)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-Open"><strong>Open</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-PutBack"><strong>PutBack</strong></a>(self, char)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-Read"><strong>Read</strong></a>(self, length)</dt><dd><tt>Try to read the given count of data (length) and returns the<br>
|
||||
successfully readed number of data. The function never blocks.<br>
|
||||
For example:<br>
|
||||
readed = dev.<a href="#wxIOBase-Read">Read</a>(100)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-ReadBinary"><strong>ReadBinary</strong></a>(self, eos<font color="#909090">='<font color="#c040c0">\n</font>'</font>)</dt><dd><tt>Special SCPI command. Read the next data coded as a SCPI<br>
|
||||
binary format.<br>
|
||||
A binary data transfer will be startet by '#'. The next byte<br>
|
||||
tells the count of bytes for the binary length header,<br>
|
||||
following by the length bytes. After these the data begins.<br>
|
||||
For example:<br>
|
||||
#500004xxxx<br>
|
||||
The header length covers 5 Byte, the length of the binary<br>
|
||||
data is 4 (x means the binary data bytes)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-ReadUntilEOS"><strong>ReadUntilEOS</strong></a>(self, eos<font color="#909090">='<font color="#c040c0">\n</font>'</font>, quota<font color="#909090">=0</font>)</dt><dd><tt><a href="#wxIOBase-ReadUntilEOS">ReadUntilEOS</a>(eosString="\n",timeout=1000)<br>
|
||||
Reads data until the given eos string was received (default is<br>
|
||||
the linefeed character (0x0a) or the internal timeout<br>
|
||||
(default 1000ms) was reached.<br>
|
||||
ReadUntilEOS returns the result as the following tuple:<br>
|
||||
['received string',state,readedBytes]<br>
|
||||
If a timeout occurred, state is 0, otherwise 1</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-Readv"><strong>Readv</strong></a>(self, length)</dt><dd><tt>Try to read the given count of data. Readv blocks until all data<br>
|
||||
was readed successfully or the internal timeout, set with the<br>
|
||||
class member function <a href="#wxIOBase-SetTimeout">SetTimeout</a>(timeout), was reached.<br>
|
||||
Returns the readed data.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-ResetBus"><strong>ResetBus</strong></a>(self)</dt><dd><tt>If the underlaying interface needs some special reset operations<br>
|
||||
(for instance the GPIB distinguish between a normal device reset<br>
|
||||
and a special bus reset), you can put some code here)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-SetTimeout"><strong>SetTimeout</strong></a>(self, timeout)</dt><dd><tt>Set the internal timeout value in milliseconds for all blocked<br>
|
||||
operations like ReadUntilEOS, Readv and Writev.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-Write"><strong>Write</strong></a>(self, string)</dt><dd><tt>Writes the given string to the device and returns immediately.<br>
|
||||
Write returns the number of data bytes successfully written or a<br>
|
||||
negativ number if an error occured. For some circumstances, not<br>
|
||||
the complete string was written.<br>
|
||||
So you have to verify the return value to check this out.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-Writev"><strong>Writev</strong></a>(self, string)</dt><dd><tt>Writes the given string to the device. The function blocks until<br>
|
||||
the complete string was written or the internal timeout, set with<br>
|
||||
<a href="#wxIOBase-SetTimeout">SetTimeout</a>(timeout), was reached.<br>
|
||||
Writev returns the number of data successfully written or a<br>
|
||||
negativ value, if an errors occurred.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-__del__"><strong>__del__</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxIOBase-__init__"><strong>__init__</strong></a>(self)</dt></dl>
|
||||
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="wxSerialPort">class <strong>wxSerialPort</strong></a>(<a href="ctb.html#wxIOBase">wxIOBase</a>)</font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="wxSerialPort-ChangeLineState"><strong>ChangeLineState</strong></a>(self, lineState)</dt><dd><tt>Change (toggle) the state of each the lines given in the<br>
|
||||
linestate parameter. Possible values are wxSERIAL_LINESTATE_DTR<br>
|
||||
(means the DTR signal) and/or wxSERIAL_LINESTATE_RTS (RTS signal).<br>
|
||||
For example to toggle the RTS line only:<br>
|
||||
dev.<a href="#wxSerialPort-ChangeLineState">ChangeLineState</a>(wxSERIAL_LINESTATE_RTS)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-ClrLineState"><strong>ClrLineState</strong></a>(self, lineState)</dt><dd><tt>Clear the lines given in the linestate parameter. Possible<br>
|
||||
values are wxSERIAL_LINESTATE_DTR (means the DTR signal) and/or<br>
|
||||
wxSERIAL_LINESTATE_RTS (RTS signal). For example to clear only<br>
|
||||
the RTS line:<br>
|
||||
dev.<a href="#wxSerialPort-ClrLineState">ClrLineState</a>(wxSERIAL_LINESTATE_RTS)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-GetAvailableBytes"><strong>GetAvailableBytes</strong></a>(self)</dt><dd><tt>Returns the available bytes in the input queue of the serial<br>
|
||||
driver.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-GetCommErrors"><strong>GetCommErrors</strong></a>(self)</dt><dd><tt>Get the internal communication errors like breaks, framing,<br>
|
||||
parity or overrun errors.<br>
|
||||
Returns the count of each error as a tuple like this:<br>
|
||||
(b,f,o,p) = dev.<a href="#wxSerialPort-GetCommErrors">GetCommErrors</a>()<br>
|
||||
b: breaks, f: framing errors, o: overruns, p: parity errors</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-GetLineState"><strong>GetLineState</strong></a>(self)</dt><dd><tt>Returns the current linestates of the CTS, DCD, DSR and RING<br>
|
||||
signal line as an integer value with the appropriate bits or<br>
|
||||
-1 on error.<br>
|
||||
For example:<br>
|
||||
lines = dev.<a href="#wxSerialPort-GetLineState">GetLineState</a>()<br>
|
||||
if lines & wxSERIAL_LINESTATE_CTS:<br>
|
||||
print "CTS is on"</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-Open"><strong>Open</strong></a>(self, devname, baudrate, protocol<font color="#909090">='8N1'</font>, handshake<font color="#909090">='no_handshake'</font>)</dt><dd><tt>Open the device devname with the given baudrate, the protocol<br>
|
||||
like '8N1' (default) and the use of the handshake [no_handshake<br>
|
||||
(default), rtscts or xonxoff]<br>
|
||||
For example:<br>
|
||||
At Linux:<br>
|
||||
dev = <a href="#wxSerialPort">wxSerialPort</a>()<br>
|
||||
dev.<a href="#wxSerialPort-Open">Open</a>("/dev/ttyS0",115200)<br>
|
||||
or with a datalen of 7 bits, even parity, 2 stopbits and rts/cts<br>
|
||||
handshake:<br>
|
||||
dev.<a href="#wxSerialPort-Open">Open</a>("/dev/ttyS0",115200,'7E2',True)<br>
|
||||
At Windows:<br>
|
||||
dev = <a href="#wxSerialPort">wxSerialPort</a>()<br>
|
||||
dev.<a href="#wxSerialPort-Open">Open</a>("COM1",115200)<br>
|
||||
dev.<a href="#wxSerialPort-Open">Open</a>("COM1",115200,'7E2',True)<br>
|
||||
Returns the handle on success or a negativ value on failure.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-Reset"><strong>Reset</strong></a>(self)</dt><dd><tt>Send a break for 0.25s.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-SetBaudRate"><strong>SetBaudRate</strong></a>(self, baudrate)</dt><dd><tt>Set the baudrate for the device.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-SetLineState"><strong>SetLineState</strong></a>(self, lineState)</dt><dd><tt>Set the lines given in the linestate parameter. Possible<br>
|
||||
values are wxSERIAL_LINESTATE_DTR (means the DTR signal) and/or<br>
|
||||
wxSERIAL_LINESTATE_RTS (RTS signal). For example to set both:<br>
|
||||
dev.<a href="#wxSerialPort-SetLineState">SetLineState</a>(wxSERIAL_LINESTATE_DTR | wxSERIAL_LINESTATE_RTS)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-__del__"><strong>__del__</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-__init__"><strong>__init__</strong></a>(self)</dt></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="ctb.html#wxIOBase">wxIOBase</a>:<br>
|
||||
<dl><dt><a name="wxSerialPort-Close"><strong>Close</strong></a>(self)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-GetTimeout"><strong>GetTimeout</strong></a>(self)</dt><dd><tt>Returns the internal timeout value in milliseconds</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-Ioctl"><strong>Ioctl</strong></a>(self, cmd, arg)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-PutBack"><strong>PutBack</strong></a>(self, char)</dt></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-Read"><strong>Read</strong></a>(self, length)</dt><dd><tt>Try to read the given count of data (length) and returns the<br>
|
||||
successfully readed number of data. The function never blocks.<br>
|
||||
For example:<br>
|
||||
readed = dev.<a href="#wxSerialPort-Read">Read</a>(100)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-ReadBinary"><strong>ReadBinary</strong></a>(self, eos<font color="#909090">='<font color="#c040c0">\n</font>'</font>)</dt><dd><tt>Special SCPI command. Read the next data coded as a SCPI<br>
|
||||
binary format.<br>
|
||||
A binary data transfer will be startet by '#'. The next byte<br>
|
||||
tells the count of bytes for the binary length header,<br>
|
||||
following by the length bytes. After these the data begins.<br>
|
||||
For example:<br>
|
||||
#500004xxxx<br>
|
||||
The header length covers 5 Byte, the length of the binary<br>
|
||||
data is 4 (x means the binary data bytes)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-ReadUntilEOS"><strong>ReadUntilEOS</strong></a>(self, eos<font color="#909090">='<font color="#c040c0">\n</font>'</font>, quota<font color="#909090">=0</font>)</dt><dd><tt><a href="#wxSerialPort-ReadUntilEOS">ReadUntilEOS</a>(eosString="\n",timeout=1000)<br>
|
||||
Reads data until the given eos string was received (default is<br>
|
||||
the linefeed character (0x0a) or the internal timeout<br>
|
||||
(default 1000ms) was reached.<br>
|
||||
ReadUntilEOS returns the result as the following tuple:<br>
|
||||
['received string',state,readedBytes]<br>
|
||||
If a timeout occurred, state is 0, otherwise 1</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-Readv"><strong>Readv</strong></a>(self, length)</dt><dd><tt>Try to read the given count of data. Readv blocks until all data<br>
|
||||
was readed successfully or the internal timeout, set with the<br>
|
||||
class member function <a href="#wxSerialPort-SetTimeout">SetTimeout</a>(timeout), was reached.<br>
|
||||
Returns the readed data.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-ResetBus"><strong>ResetBus</strong></a>(self)</dt><dd><tt>If the underlaying interface needs some special reset operations<br>
|
||||
(for instance the GPIB distinguish between a normal device reset<br>
|
||||
and a special bus reset), you can put some code here)</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-SetTimeout"><strong>SetTimeout</strong></a>(self, timeout)</dt><dd><tt>Set the internal timeout value in milliseconds for all blocked<br>
|
||||
operations like ReadUntilEOS, Readv and Writev.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-Write"><strong>Write</strong></a>(self, string)</dt><dd><tt>Writes the given string to the device and returns immediately.<br>
|
||||
Write returns the number of data bytes successfully written or a<br>
|
||||
negativ number if an error occured. For some circumstances, not<br>
|
||||
the complete string was written.<br>
|
||||
So you have to verify the return value to check this out.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="wxSerialPort-Writev"><strong>Writev</strong></a>(self, string)</dt><dd><tt>Writes the given string to the device. The function blocks until<br>
|
||||
the complete string was written or the internal timeout, set with<br>
|
||||
<a href="#wxSerialPort-SetTimeout">SetTimeout</a>(timeout), was reached.<br>
|
||||
Writev returns the number of data successfully written or a<br>
|
||||
negativ value, if an errors occurred.</tt></dd></dl>
|
||||
|
||||
</td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#eeaa77">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl><dt><a name="-GetKey"><strong>GetKey</strong></a>()</dt><dd><tt>Returns the current pressed key or ' | ||||