mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-09 06:13:53 +01:00
Mit errorhandling zusammenführen
This commit is contained in:
@@ -22,7 +22,7 @@ __author__ = "Sven Sager <akira@revpimodio.org>"
|
||||
__copyright__ = "Copyright (C) 2018 Sven Sager"
|
||||
__license__ = "LGPLv3"
|
||||
__name__ = "revpimodio2"
|
||||
__version__ = "2.3.1"
|
||||
__version__ = "2.3.2"
|
||||
|
||||
# Global package values
|
||||
OFF = 0
|
||||
|
||||
@@ -779,7 +779,7 @@ class Connect(Core):
|
||||
exp_x2out = exp_a3green
|
||||
exp_wd = exp_a3green
|
||||
lst_status = lst_myios[self._slc_statusbyte.start]
|
||||
if len(lst_led) == 8:
|
||||
if len(lst_status) == 8:
|
||||
exp_x2in = lst_status[6].export
|
||||
else:
|
||||
exp_x2in = lst_status[0].export
|
||||
|
||||
@@ -807,13 +807,28 @@ class IntIOCounter(IntIO):
|
||||
@see #IOBase.__init__ IOBase.__init__(...)
|
||||
|
||||
"""
|
||||
if not (isinstance(counter_id, int) and 0 <= counter_id <= 15):
|
||||
raise ValueError("counter_id must be <class 'int'> and 0 - 15")
|
||||
if not isinstance(counter_id, int):
|
||||
raise TypeError("counter_id must be <class 'int'>")
|
||||
if not 0 <= counter_id <= 15:
|
||||
raise ValueError("counter_id must be 0 - 15")
|
||||
|
||||
# Deviceposition + Counter_ID
|
||||
# Deviceposition + leer + Counter_ID
|
||||
# ID-Bits: 7|6|5|4|3|2|1|0|15|14|13|12|11|10|9|8
|
||||
self.__ioctl_arg = \
|
||||
parentdevice._position.to_bytes(1, "little") + \
|
||||
(1 << counter_id).to_bytes(2, "big")
|
||||
parentdevice._position.to_bytes(1, "little") + b'\x00' + \
|
||||
(1 << counter_id).to_bytes(2, "little")
|
||||
|
||||
"""
|
||||
IOCTL fuellt dieses struct, welches durch padding im Speicher nach
|
||||
uint8_t ein byte frei hat. Es muessen also 4 Byte uebergeben werden
|
||||
wobei das Bitfield die Byteorder little hat!!!
|
||||
|
||||
typedef struct SDIOResetCounterStr
|
||||
{
|
||||
uint8_t i8uAddress; // Address of module
|
||||
uint16_t i16uBitfield; // bitfield, if bit n is 1, reset
|
||||
} SDIOResetCounter;
|
||||
"""
|
||||
|
||||
# Basisklasse laden
|
||||
super().__init__(parentdevice, valuelist, iotype, byteorder, signed)
|
||||
@@ -873,7 +888,11 @@ class IntIOReplaceable(IntIO):
|
||||
|
||||
Es darf nur ein einzelnes Formatzeichen 'frm' uebergeben werden. Daraus
|
||||
wird dann die benoetigte Laenge an Bytes berechnet und der Datentyp
|
||||
festgelegt.
|
||||
festgelegt. Moeglich sind:
|
||||
Bits / Bytes: ?, c, s
|
||||
Integer : bB, hH, iI, lL, qQ
|
||||
Float : e, f, d
|
||||
|
||||
Eine Ausnahme ist die Formatierung 's'. Hier koennen mehrere Bytes
|
||||
zu einem langen IO zusammengefasst werden. Die Formatierung muss
|
||||
'8s' fuer z.B. 8 Bytes sein - NICHT 'ssssssss'!
|
||||
@@ -946,10 +965,10 @@ class StructIO(IOBase):
|
||||
- defaultvalue: Standardwert fuer IO, Standard vom ersetzter IO
|
||||
|
||||
"""
|
||||
# Mehrfach s prüfen 8s
|
||||
regex = rematch("[0-9]*s", frm)
|
||||
# Structformatierung prüfen
|
||||
regex = rematch("^([0-9]*s|[cbB?hHiIlLqQefd])$", frm)
|
||||
|
||||
if len(frm) == 1 or regex is not None and regex.end() == len(frm):
|
||||
if regex is not None:
|
||||
# Byteorder prüfen und übernehmen
|
||||
byteorder = kwargs.get("byteorder", parentio._byteorder)
|
||||
if not (byteorder == "little" or byteorder == "big"):
|
||||
@@ -990,7 +1009,8 @@ class StructIO(IOBase):
|
||||
]
|
||||
else:
|
||||
raise ValueError(
|
||||
"parameter frm has to be a single sign or 'COUNTs' e.g. '8s'"
|
||||
"parameter frm has to be a single sign from [cbB?hHiIlLqQefd] "
|
||||
"or 'COUNTs' e.g. '8s'"
|
||||
)
|
||||
|
||||
# Basisklasse instantiieren
|
||||
|
||||
Reference in New Issue
Block a user