repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
faucamp/python-gsmmodem
gsmmodem/modem.py
IncomingCall.answer
def answer(self): """ Answer the phone call. :return: self (for chaining method calls) """ if self.ringing: self._gsmModem.write('ATA') self.ringing = False self.answered = True return self
python
def answer(self): """ Answer the phone call. :return: self (for chaining method calls) """ if self.ringing: self._gsmModem.write('ATA') self.ringing = False self.answered = True return self
[ "def", "answer", "(", "self", ")", ":", "if", "self", ".", "ringing", ":", "self", ".", "_gsmModem", ".", "write", "(", "'ATA'", ")", "self", ".", "ringing", "=", "False", "self", ".", "answered", "=", "True", "return", "self" ]
Answer the phone call. :return: self (for chaining method calls)
[ "Answer", "the", "phone", "call", ".", ":", "return", ":", "self", "(", "for", "chaining", "method", "calls", ")" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/modem.py#L1308-L1316
faucamp/python-gsmmodem
gsmmodem/modem.py
Ussd.reply
def reply(self, message): """ Sends a reply to this USSD message in the same USSD session :raise InvalidStateException: if the USSD session is not active (i.e. it has ended) :return: The USSD response message/session (as a Ussd object) """ if self.sessionActive...
python
def reply(self, message): """ Sends a reply to this USSD message in the same USSD session :raise InvalidStateException: if the USSD session is not active (i.e. it has ended) :return: The USSD response message/session (as a Ussd object) """ if self.sessionActive...
[ "def", "reply", "(", "self", ",", "message", ")", ":", "if", "self", ".", "sessionActive", ":", "return", "self", ".", "_gsmModem", ".", "sendUssd", "(", "message", ")", "else", ":", "raise", "InvalidStateException", "(", "'USSD session is inactive'", ")" ]
Sends a reply to this USSD message in the same USSD session :raise InvalidStateException: if the USSD session is not active (i.e. it has ended) :return: The USSD response message/session (as a Ussd object)
[ "Sends", "a", "reply", "to", "this", "USSD", "message", "in", "the", "same", "USSD", "session", ":", "raise", "InvalidStateException", ":", "if", "the", "USSD", "session", "is", "not", "active", "(", "i", ".", "e", ".", "it", "has", "ended", ")", ":", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/modem.py#L1336-L1346
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
RawTerm._inputLoop
def _inputLoop(self): """ Loop and copy console->serial until EXIT_CHARCTER character is found. """ try: while self.alive: try: c = console.getkey() except KeyboardInterrupt: print('kbint') ...
python
def _inputLoop(self): """ Loop and copy console->serial until EXIT_CHARCTER character is found. """ try: while self.alive: try: c = console.getkey() except KeyboardInterrupt: print('kbint') ...
[ "def", "_inputLoop", "(", "self", ")", ":", "try", ":", "while", "self", ".", "alive", ":", "try", ":", "c", "=", "console", ".", "getkey", "(", ")", "except", "KeyboardInterrupt", ":", "print", "(", "'kbint'", ")", "c", "=", "serial", ".", "to_bytes...
Loop and copy console->serial until EXIT_CHARCTER character is found.
[ "Loop", "and", "copy", "console", "-", ">", "serial", "until", "EXIT_CHARCTER", "character", "is", "found", "." ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L142-L168
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._color
def _color(self, color, msg): """ Converts a message to be printed to the user's terminal in red """ if self.useColor: return '{0}{1}{2}'.format(color, msg, self.RESET_SEQ) else: return msg
python
def _color(self, color, msg): """ Converts a message to be printed to the user's terminal in red """ if self.useColor: return '{0}{1}{2}'.format(color, msg, self.RESET_SEQ) else: return msg
[ "def", "_color", "(", "self", ",", "color", ",", "msg", ")", ":", "if", "self", ".", "useColor", ":", "return", "'{0}{1}{2}'", ".", "format", "(", "color", ",", "msg", ",", "self", ".", "RESET_SEQ", ")", "else", ":", "return", "msg" ]
Converts a message to be printed to the user's terminal in red
[ "Converts", "a", "message", "to", "be", "printed", "to", "the", "user", "s", "terminal", "in", "red" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L216-L221
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._inputLoop
def _inputLoop(self): """ Loop and copy console->serial until EXIT_CHARCTER character is found. """ # Switch statement for handling "special" characters actionChars = {self.EXIT_CHARACTER: self._exit, self.EXIT_CHARACTER_2: self._exit, ...
python
def _inputLoop(self): """ Loop and copy console->serial until EXIT_CHARCTER character is found. """ # Switch statement for handling "special" characters actionChars = {self.EXIT_CHARACTER: self._exit, self.EXIT_CHARACTER_2: self._exit, ...
[ "def", "_inputLoop", "(", "self", ")", ":", "# Switch statement for handling \"special\" characters", "actionChars", "=", "{", "self", ".", "EXIT_CHARACTER", ":", "self", ".", "_exit", ",", "self", ".", "EXIT_CHARACTER_2", ":", "self", ".", "_exit", ",", "console"...
Loop and copy console->serial until EXIT_CHARCTER character is found.
[ "Loop", "and", "copy", "console", "-", ">", "serial", "until", "EXIT_CHARCTER", "character", "is", "found", "." ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L243-L284
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._handleCtrlZ
def _handleCtrlZ(self): """ Handler for CTRL+Z keypresses """ if self._typingSms: self.serial.write(''.join(self.inputBuffer)) self.serial.write(self.CTRL_Z_CHARACTER) self._typingSms = False self.inputBuffer = [] self.cursorPos = 0 ...
python
def _handleCtrlZ(self): """ Handler for CTRL+Z keypresses """ if self._typingSms: self.serial.write(''.join(self.inputBuffer)) self.serial.write(self.CTRL_Z_CHARACTER) self._typingSms = False self.inputBuffer = [] self.cursorPos = 0 ...
[ "def", "_handleCtrlZ", "(", "self", ")", ":", "if", "self", ".", "_typingSms", ":", "self", ".", "serial", ".", "write", "(", "''", ".", "join", "(", "self", ".", "inputBuffer", ")", ")", "self", ".", "serial", ".", "write", "(", "self", ".", "CTRL...
Handler for CTRL+Z keypresses
[ "Handler", "for", "CTRL", "+", "Z", "keypresses" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L286-L295
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._handleEsc
def _handleEsc(self): """ Handler for CTRL+Z keypresses """ if self._typingSms: self.serial.write(self.ESC_CHARACTER) self._typingSms = False self.inputBuffer = [] self.cursorPos = 0
python
def _handleEsc(self): """ Handler for CTRL+Z keypresses """ if self._typingSms: self.serial.write(self.ESC_CHARACTER) self._typingSms = False self.inputBuffer = [] self.cursorPos = 0
[ "def", "_handleEsc", "(", "self", ")", ":", "if", "self", ".", "_typingSms", ":", "self", ".", "serial", ".", "write", "(", "self", ".", "ESC_CHARACTER", ")", "self", ".", "_typingSms", "=", "False", "self", ".", "inputBuffer", "=", "[", "]", "self", ...
Handler for CTRL+Z keypresses
[ "Handler", "for", "CTRL", "+", "Z", "keypresses" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L297-L303
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._exit
def _exit(self): """ Shuts down the terminal (and app) """ self._removeInputPrompt() print(self._color(self.COLOR_YELLOW, 'CLOSING TERMINAL...')) self.stop()
python
def _exit(self): """ Shuts down the terminal (and app) """ self._removeInputPrompt() print(self._color(self.COLOR_YELLOW, 'CLOSING TERMINAL...')) self.stop()
[ "def", "_exit", "(", "self", ")", ":", "self", ".", "_removeInputPrompt", "(", ")", "print", "(", "self", ".", "_color", "(", "self", ".", "COLOR_YELLOW", ",", "'CLOSING TERMINAL...'", ")", ")", "self", ".", "stop", "(", ")" ]
Shuts down the terminal (and app)
[ "Shuts", "down", "the", "terminal", "(", "and", "app", ")" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L305-L309
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._cursorLeft
def _cursorLeft(self): """ Handles "cursor left" events """ if self.cursorPos > 0: self.cursorPos -= 1 sys.stdout.write(console.CURSOR_LEFT) sys.stdout.flush()
python
def _cursorLeft(self): """ Handles "cursor left" events """ if self.cursorPos > 0: self.cursorPos -= 1 sys.stdout.write(console.CURSOR_LEFT) sys.stdout.flush()
[ "def", "_cursorLeft", "(", "self", ")", ":", "if", "self", ".", "cursorPos", ">", "0", ":", "self", ".", "cursorPos", "-=", "1", "sys", ".", "stdout", ".", "write", "(", "console", ".", "CURSOR_LEFT", ")", "sys", ".", "stdout", ".", "flush", "(", "...
Handles "cursor left" events
[ "Handles", "cursor", "left", "events" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L311-L316
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._cursorRight
def _cursorRight(self): """ Handles "cursor right" events """ if self.cursorPos < len(self.inputBuffer): self.cursorPos += 1 sys.stdout.write(console.CURSOR_RIGHT) sys.stdout.flush()
python
def _cursorRight(self): """ Handles "cursor right" events """ if self.cursorPos < len(self.inputBuffer): self.cursorPos += 1 sys.stdout.write(console.CURSOR_RIGHT) sys.stdout.flush()
[ "def", "_cursorRight", "(", "self", ")", ":", "if", "self", ".", "cursorPos", "<", "len", "(", "self", ".", "inputBuffer", ")", ":", "self", ".", "cursorPos", "+=", "1", "sys", ".", "stdout", ".", "write", "(", "console", ".", "CURSOR_RIGHT", ")", "s...
Handles "cursor right" events
[ "Handles", "cursor", "right", "events" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L318-L323
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._cursorUp
def _cursorUp(self): """ Handles "cursor up" events """ if self.historyPos > 0: self.historyPos -= 1 clearLen = len(self.inputBuffer) self.inputBuffer = list(self.history[self.historyPos]) self.cursorPos = len(self.inputBuffer) self._refreshInp...
python
def _cursorUp(self): """ Handles "cursor up" events """ if self.historyPos > 0: self.historyPos -= 1 clearLen = len(self.inputBuffer) self.inputBuffer = list(self.history[self.historyPos]) self.cursorPos = len(self.inputBuffer) self._refreshInp...
[ "def", "_cursorUp", "(", "self", ")", ":", "if", "self", ".", "historyPos", ">", "0", ":", "self", ".", "historyPos", "-=", "1", "clearLen", "=", "len", "(", "self", ".", "inputBuffer", ")", "self", ".", "inputBuffer", "=", "list", "(", "self", ".", ...
Handles "cursor up" events
[ "Handles", "cursor", "up", "events" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L325-L332
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._handleBackspace
def _handleBackspace(self): """ Handles backspace characters """ if self.cursorPos > 0: #print( 'cp:',self.cursorPos,'was:', self.inputBuffer) self.inputBuffer = self.inputBuffer[0:self.cursorPos-1] + self.inputBuffer[self.cursorPos:] self.cursorPos -= 1 #...
python
def _handleBackspace(self): """ Handles backspace characters """ if self.cursorPos > 0: #print( 'cp:',self.cursorPos,'was:', self.inputBuffer) self.inputBuffer = self.inputBuffer[0:self.cursorPos-1] + self.inputBuffer[self.cursorPos:] self.cursorPos -= 1 #...
[ "def", "_handleBackspace", "(", "self", ")", ":", "if", "self", ".", "cursorPos", ">", "0", ":", "#print( 'cp:',self.cursorPos,'was:', self.inputBuffer)", "self", ".", "inputBuffer", "=", "self", ".", "inputBuffer", "[", "0", ":", "self", ".", "cursorPos", "-", ...
Handles backspace characters
[ "Handles", "backspace", "characters" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L343-L350
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._handleDelete
def _handleDelete(self): """ Handles "delete" characters """ if self.cursorPos < len(self.inputBuffer): self.inputBuffer = self.inputBuffer[0:self.cursorPos] + self.inputBuffer[self.cursorPos+1:] self._refreshInputPrompt(len(self.inputBuffer)+1)
python
def _handleDelete(self): """ Handles "delete" characters """ if self.cursorPos < len(self.inputBuffer): self.inputBuffer = self.inputBuffer[0:self.cursorPos] + self.inputBuffer[self.cursorPos+1:] self._refreshInputPrompt(len(self.inputBuffer)+1)
[ "def", "_handleDelete", "(", "self", ")", ":", "if", "self", ".", "cursorPos", "<", "len", "(", "self", ".", "inputBuffer", ")", ":", "self", ".", "inputBuffer", "=", "self", ".", "inputBuffer", "[", "0", ":", "self", ".", "cursorPos", "]", "+", "sel...
Handles "delete" characters
[ "Handles", "delete", "characters" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L352-L356
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._handleEnd
def _handleEnd(self): """ Handles "end" character """ self.cursorPos = len(self.inputBuffer) self._refreshInputPrompt(len(self.inputBuffer))
python
def _handleEnd(self): """ Handles "end" character """ self.cursorPos = len(self.inputBuffer) self._refreshInputPrompt(len(self.inputBuffer))
[ "def", "_handleEnd", "(", "self", ")", ":", "self", ".", "cursorPos", "=", "len", "(", "self", ".", "inputBuffer", ")", "self", ".", "_refreshInputPrompt", "(", "len", "(", "self", ".", "inputBuffer", ")", ")" ]
Handles "end" character
[ "Handles", "end", "character" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L363-L366
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm._doCommandCompletion
def _doCommandCompletion(self): """ Command-completion method """ prefix = ''.join(self.inputBuffer).strip().upper() matches = self.completion.keys(prefix) matchLen = len(matches) if matchLen == 0 and prefix[-1] == '=': try: ...
python
def _doCommandCompletion(self): """ Command-completion method """ prefix = ''.join(self.inputBuffer).strip().upper() matches = self.completion.keys(prefix) matchLen = len(matches) if matchLen == 0 and prefix[-1] == '=': try: ...
[ "def", "_doCommandCompletion", "(", "self", ")", ":", "prefix", "=", "''", ".", "join", "(", "self", ".", "inputBuffer", ")", ".", "strip", "(", ")", ".", "upper", "(", ")", "matches", "=", "self", ".", "completion", ".", "keys", "(", "prefix", ")", ...
Command-completion method
[ "Command", "-", "completion", "method" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L533-L568
faucamp/python-gsmmodem
tools/gsmtermlib/terminal.py
GsmTerm.__printCommandSyntax
def __printCommandSyntax(self, command): """ Command-completion helper method: print command syntax """ commandHelp = self.completion[command] if commandHelp != None and len(commandHelp) > 2: commandValues = commandHelp[2] #commandDefault = commandHelp[3] disp...
python
def __printCommandSyntax(self, command): """ Command-completion helper method: print command syntax """ commandHelp = self.completion[command] if commandHelp != None and len(commandHelp) > 2: commandValues = commandHelp[2] #commandDefault = commandHelp[3] disp...
[ "def", "__printCommandSyntax", "(", "self", ",", "command", ")", ":", "commandHelp", "=", "self", ".", "completion", "[", "command", "]", "if", "commandHelp", "!=", "None", "and", "len", "(", "commandHelp", ")", ">", "2", ":", "commandValues", "=", "comman...
Command-completion helper method: print command syntax
[ "Command", "-", "completion", "helper", "method", ":", "print", "command", "syntax" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L570-L584
faucamp/python-gsmmodem
gsmmodem/serial_comms.py
SerialComms.connect
def connect(self): """ Connects to the device and starts the read thread """ self.serial = serial.Serial(port=self.port, baudrate=self.baudrate, timeout=self.timeout) # Start read thread self.alive = True self.rxThread = threading.Thread(target=self._readLoop) ...
python
def connect(self): """ Connects to the device and starts the read thread """ self.serial = serial.Serial(port=self.port, baudrate=self.baudrate, timeout=self.timeout) # Start read thread self.alive = True self.rxThread = threading.Thread(target=self._readLoop) ...
[ "def", "connect", "(", "self", ")", ":", "self", ".", "serial", "=", "serial", ".", "Serial", "(", "port", "=", "self", ".", "port", ",", "baudrate", "=", "self", ".", "baudrate", ",", "timeout", "=", "self", ".", "timeout", ")", "# Start read thread",...
Connects to the device and starts the read thread
[ "Connects", "to", "the", "device", "and", "starts", "the", "read", "thread" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/serial_comms.py#L45-L52
faucamp/python-gsmmodem
gsmmodem/serial_comms.py
SerialComms.close
def close(self): """ Stops the read thread, waits for it to exit cleanly, then closes the underlying serial port """ self.alive = False self.rxThread.join() self.serial.close()
python
def close(self): """ Stops the read thread, waits for it to exit cleanly, then closes the underlying serial port """ self.alive = False self.rxThread.join() self.serial.close()
[ "def", "close", "(", "self", ")", ":", "self", ".", "alive", "=", "False", "self", ".", "rxThread", ".", "join", "(", ")", "self", ".", "serial", ".", "close", "(", ")" ]
Stops the read thread, waits for it to exit cleanly, then closes the underlying serial port
[ "Stops", "the", "read", "thread", "waits", "for", "it", "to", "exit", "cleanly", "then", "closes", "the", "underlying", "serial", "port" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/serial_comms.py#L54-L58
faucamp/python-gsmmodem
gsmmodem/serial_comms.py
SerialComms._readLoop
def _readLoop(self): """ Read thread main loop Reads lines from the connected device """ try: readTermSeq = list(self.RX_EOL_SEQ) readTermLen = len(readTermSeq) rxBuffer = [] while self.alive: data = self.serial.rea...
python
def _readLoop(self): """ Read thread main loop Reads lines from the connected device """ try: readTermSeq = list(self.RX_EOL_SEQ) readTermLen = len(readTermSeq) rxBuffer = [] while self.alive: data = self.serial.rea...
[ "def", "_readLoop", "(", "self", ")", ":", "try", ":", "readTermSeq", "=", "list", "(", "self", ".", "RX_EOL_SEQ", ")", "readTermLen", "=", "len", "(", "readTermSeq", ")", "rxBuffer", "=", "[", "]", "while", "self", ".", "alive", ":", "data", "=", "s...
Read thread main loop Reads lines from the connected device
[ "Read", "thread", "main", "loop", "Reads", "lines", "from", "the", "connected", "device" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/serial_comms.py#L83-L118
faucamp/python-gsmmodem
tools/gsmtermlib/trie.py
Trie._allKeys
def _allKeys(self, prefix): """ Private implementation method. Use keys() instead. """ global dictItemsIter result = [prefix + self.key] if self.key != None else [] for key, trie in dictItemsIter(self.slots): result.extend(trie._allKeys(prefix + key)) ...
python
def _allKeys(self, prefix): """ Private implementation method. Use keys() instead. """ global dictItemsIter result = [prefix + self.key] if self.key != None else [] for key, trie in dictItemsIter(self.slots): result.extend(trie._allKeys(prefix + key)) ...
[ "def", "_allKeys", "(", "self", ",", "prefix", ")", ":", "global", "dictItemsIter", "result", "=", "[", "prefix", "+", "self", ".", "key", "]", "if", "self", ".", "key", "!=", "None", "else", "[", "]", "for", "key", ",", "trie", "in", "dictItemsIter"...
Private implementation method. Use keys() instead.
[ "Private", "implementation", "method", ".", "Use", "keys", "()", "instead", "." ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/trie.py#L117-L123
faucamp/python-gsmmodem
gsmmodem/pdu.py
encodeSmsSubmitPdu
def encodeSmsSubmitPdu(number, text, reference=0, validity=None, smsc=None, requestStatusReport=True, rejectDuplicates=False, sendFlash=False): """ Creates an SMS-SUBMIT PDU for sending a message with the specified text to the specified number :param number: the destination mobile number :type number: ...
python
def encodeSmsSubmitPdu(number, text, reference=0, validity=None, smsc=None, requestStatusReport=True, rejectDuplicates=False, sendFlash=False): """ Creates an SMS-SUBMIT PDU for sending a message with the specified text to the specified number :param number: the destination mobile number :type number: ...
[ "def", "encodeSmsSubmitPdu", "(", "number", ",", "text", ",", "reference", "=", "0", ",", "validity", "=", "None", ",", "smsc", "=", "None", ",", "requestStatusReport", "=", "True", ",", "rejectDuplicates", "=", "False", ",", "sendFlash", "=", "False", ")"...
Creates an SMS-SUBMIT PDU for sending a message with the specified text to the specified number :param number: the destination mobile number :type number: str :param text: the message text :type text: str :param reference: message reference number (see also: rejectDuplicates parameter) :typ...
[ "Creates", "an", "SMS", "-", "SUBMIT", "PDU", "for", "sending", "a", "message", "with", "the", "specified", "text", "to", "the", "specified", "number", ":", "param", "number", ":", "the", "destination", "mobile", "number", ":", "type", "number", ":", "str"...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L238-L355
faucamp/python-gsmmodem
gsmmodem/pdu.py
decodeSmsPdu
def decodeSmsPdu(pdu): """ Decodes SMS pdu data and returns a tuple in format (number, text) :param pdu: PDU data as a hex string, or a bytearray containing PDU octects :type pdu: str or bytearray :raise EncodingError: If the specified PDU data cannot be decoded :return: The decoded S...
python
def decodeSmsPdu(pdu): """ Decodes SMS pdu data and returns a tuple in format (number, text) :param pdu: PDU data as a hex string, or a bytearray containing PDU octects :type pdu: str or bytearray :raise EncodingError: If the specified PDU data cannot be decoded :return: The decoded S...
[ "def", "decodeSmsPdu", "(", "pdu", ")", ":", "try", ":", "pdu", "=", "toByteArray", "(", "pdu", ")", "except", "Exception", "as", "e", ":", "# Python 2 raises TypeError, Python 3 raises binascii.Error", "raise", "EncodingError", "(", "e", ")", "result", "=", "{"...
Decodes SMS pdu data and returns a tuple in format (number, text) :param pdu: PDU data as a hex string, or a bytearray containing PDU octects :type pdu: str or bytearray :raise EncodingError: If the specified PDU data cannot be decoded :return: The decoded SMS data as a dictionary :rt...
[ "Decodes", "SMS", "pdu", "data", "and", "returns", "a", "tuple", "in", "format", "(", "number", "text", ")", ":", "param", "pdu", ":", "PDU", "data", "as", "a", "hex", "string", "or", "a", "bytearray", "containing", "PDU", "octects", ":", "type", "pdu"...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L357-L418
faucamp/python-gsmmodem
gsmmodem/pdu.py
_decodeUserData
def _decodeUserData(byteIter, userDataLen, dataCoding, udhPresent): """ Decodes PDU user data (UDHI (if present) and message text) """ result = {} if udhPresent: # User Data Header is present result['udh'] = [] udhLen = next(byteIter) ieLenRead = 0 # Parse and store U...
python
def _decodeUserData(byteIter, userDataLen, dataCoding, udhPresent): """ Decodes PDU user data (UDHI (if present) and message text) """ result = {} if udhPresent: # User Data Header is present result['udh'] = [] udhLen = next(byteIter) ieLenRead = 0 # Parse and store U...
[ "def", "_decodeUserData", "(", "byteIter", ",", "userDataLen", ",", "dataCoding", ",", "udhPresent", ")", ":", "result", "=", "{", "}", "if", "udhPresent", ":", "# User Data Header is present", "result", "[", "'udh'", "]", "=", "[", "]", "udhLen", "=", "next...
Decodes PDU user data (UDHI (if present) and message text)
[ "Decodes", "PDU", "user", "data", "(", "UDHI", "(", "if", "present", ")", "and", "message", "text", ")" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L420-L454
faucamp/python-gsmmodem
gsmmodem/pdu.py
_decodeRelativeValidityPeriod
def _decodeRelativeValidityPeriod(tpVp): """ Calculates the relative SMS validity period (based on the table in section 9.2.3.12 of GSM 03.40) :rtype: datetime.timedelta """ if tpVp <= 143: return timedelta(minutes=((tpVp + 1) * 5)) elif 144 <= tpVp <= 167: return timedelta(hours=12,...
python
def _decodeRelativeValidityPeriod(tpVp): """ Calculates the relative SMS validity period (based on the table in section 9.2.3.12 of GSM 03.40) :rtype: datetime.timedelta """ if tpVp <= 143: return timedelta(minutes=((tpVp + 1) * 5)) elif 144 <= tpVp <= 167: return timedelta(hours=12,...
[ "def", "_decodeRelativeValidityPeriod", "(", "tpVp", ")", ":", "if", "tpVp", "<=", "143", ":", "return", "timedelta", "(", "minutes", "=", "(", "(", "tpVp", "+", "1", ")", "*", "5", ")", ")", "elif", "144", "<=", "tpVp", "<=", "167", ":", "return", ...
Calculates the relative SMS validity period (based on the table in section 9.2.3.12 of GSM 03.40) :rtype: datetime.timedelta
[ "Calculates", "the", "relative", "SMS", "validity", "period", "(", "based", "on", "the", "table", "in", "section", "9", ".", "2", ".", "3", ".", "12", "of", "GSM", "03", ".", "40", ")", ":", "rtype", ":", "datetime", ".", "timedelta" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L456-L469
faucamp/python-gsmmodem
gsmmodem/pdu.py
_encodeRelativeValidityPeriod
def _encodeRelativeValidityPeriod(validityPeriod): """ Encodes the specified relative validity period timedelta into an integer for use in an SMS PDU (based on the table in section 9.2.3.12 of GSM 03.40) :param validityPeriod: The validity period to encode :type validityPeriod: datetime.timedelta ...
python
def _encodeRelativeValidityPeriod(validityPeriod): """ Encodes the specified relative validity period timedelta into an integer for use in an SMS PDU (based on the table in section 9.2.3.12 of GSM 03.40) :param validityPeriod: The validity period to encode :type validityPeriod: datetime.timedelta ...
[ "def", "_encodeRelativeValidityPeriod", "(", "validityPeriod", ")", ":", "# Python 2.6 does not have timedelta.total_seconds(), so compute it manually", "#seconds = validityPeriod.total_seconds()", "seconds", "=", "validityPeriod", ".", "seconds", "+", "(", "validityPeriod", ".", "...
Encodes the specified relative validity period timedelta into an integer for use in an SMS PDU (based on the table in section 9.2.3.12 of GSM 03.40) :param validityPeriod: The validity period to encode :type validityPeriod: datetime.timedelta :rtype: int
[ "Encodes", "the", "specified", "relative", "validity", "period", "timedelta", "into", "an", "integer", "for", "use", "in", "an", "SMS", "PDU", "(", "based", "on", "the", "table", "in", "section", "9", ".", "2", ".", "3", ".", "12", "of", "GSM", "03", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L471-L492
faucamp/python-gsmmodem
gsmmodem/pdu.py
_decodeTimestamp
def _decodeTimestamp(byteIter): """ Decodes a 7-octet timestamp """ dateStr = decodeSemiOctets(byteIter, 7) timeZoneStr = dateStr[-2:] return datetime.strptime(dateStr[:-2], '%y%m%d%H%M%S').replace(tzinfo=SmsPduTzInfo(timeZoneStr))
python
def _decodeTimestamp(byteIter): """ Decodes a 7-octet timestamp """ dateStr = decodeSemiOctets(byteIter, 7) timeZoneStr = dateStr[-2:] return datetime.strptime(dateStr[:-2], '%y%m%d%H%M%S').replace(tzinfo=SmsPduTzInfo(timeZoneStr))
[ "def", "_decodeTimestamp", "(", "byteIter", ")", ":", "dateStr", "=", "decodeSemiOctets", "(", "byteIter", ",", "7", ")", "timeZoneStr", "=", "dateStr", "[", "-", "2", ":", "]", "return", "datetime", ".", "strptime", "(", "dateStr", "[", ":", "-", "2", ...
Decodes a 7-octet timestamp
[ "Decodes", "a", "7", "-", "octet", "timestamp" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L494-L498
faucamp/python-gsmmodem
gsmmodem/pdu.py
_encodeTimestamp
def _encodeTimestamp(timestamp): """ Encodes a 7-octet timestamp from the specified date Note: the specified timestamp must have a UTC offset set; you can use gsmmodem.util.SimpleOffsetTzInfo for simple cases :param timestamp: The timestamp to encode :type timestamp: datetime.datetime ...
python
def _encodeTimestamp(timestamp): """ Encodes a 7-octet timestamp from the specified date Note: the specified timestamp must have a UTC offset set; you can use gsmmodem.util.SimpleOffsetTzInfo for simple cases :param timestamp: The timestamp to encode :type timestamp: datetime.datetime ...
[ "def", "_encodeTimestamp", "(", "timestamp", ")", ":", "if", "timestamp", ".", "tzinfo", "==", "None", ":", "raise", "ValueError", "(", "'Please specify time zone information for the timestamp (e.g. by using gsmmodem.util.SimpleOffsetTzInfo)'", ")", "# See if the timezone differe...
Encodes a 7-octet timestamp from the specified date Note: the specified timestamp must have a UTC offset set; you can use gsmmodem.util.SimpleOffsetTzInfo for simple cases :param timestamp: The timestamp to encode :type timestamp: datetime.datetime :return: The encoded timestamp :rtyp...
[ "Encodes", "a", "7", "-", "octet", "timestamp", "from", "the", "specified", "date", "Note", ":", "the", "specified", "timestamp", "must", "have", "a", "UTC", "offset", "set", ";", "you", "can", "use", "gsmmodem", ".", "util", ".", "SimpleOffsetTzInfo", "fo...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L500-L526
faucamp/python-gsmmodem
gsmmodem/pdu.py
_decodeAddressField
def _decodeAddressField(byteIter, smscField=False, log=False): """ Decodes the address field at the current position of the bytearray iterator :param byteIter: Iterator over bytearray :type byteIter: iter(bytearray) :return: Tuple containing the address value and amount of bytes read (value i...
python
def _decodeAddressField(byteIter, smscField=False, log=False): """ Decodes the address field at the current position of the bytearray iterator :param byteIter: Iterator over bytearray :type byteIter: iter(bytearray) :return: Tuple containing the address value and amount of bytes read (value i...
[ "def", "_decodeAddressField", "(", "byteIter", ",", "smscField", "=", "False", ",", "log", "=", "False", ")", ":", "addressLen", "=", "next", "(", "byteIter", ")", "if", "addressLen", ">", "0", ":", "toa", "=", "next", "(", "byteIter", ")", "ton", "=",...
Decodes the address field at the current position of the bytearray iterator :param byteIter: Iterator over bytearray :type byteIter: iter(bytearray) :return: Tuple containing the address value and amount of bytes read (value is or None if it is empty (zero-length)) :rtype: tuple
[ "Decodes", "the", "address", "field", "at", "the", "current", "position", "of", "the", "bytearray", "iterator", ":", "param", "byteIter", ":", "Iterator", "over", "bytearray", ":", "type", "byteIter", ":", "iter", "(", "bytearray", ")", ":", "return", ":", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L536-L571
faucamp/python-gsmmodem
gsmmodem/pdu.py
_encodeAddressField
def _encodeAddressField(address, smscField=False): """ Encodes the address into an address field :param address: The address to encode (phone number or alphanumeric) :type byteIter: str :return: Encoded SMS PDU address field :rtype: bytearray """ # First, see if this is a number or...
python
def _encodeAddressField(address, smscField=False): """ Encodes the address into an address field :param address: The address to encode (phone number or alphanumeric) :type byteIter: str :return: Encoded SMS PDU address field :rtype: bytearray """ # First, see if this is a number or...
[ "def", "_encodeAddressField", "(", "address", ",", "smscField", "=", "False", ")", ":", "# First, see if this is a number or an alphanumeric string", "toa", "=", "0x80", "|", "0x00", "|", "0x01", "# Type-of-address start | Unknown type-of-number | ISDN/tel numbering plan", "alp...
Encodes the address into an address field :param address: The address to encode (phone number or alphanumeric) :type byteIter: str :return: Encoded SMS PDU address field :rtype: bytearray
[ "Encodes", "the", "address", "into", "an", "address", "field", ":", "param", "address", ":", "The", "address", "to", "encode", "(", "phone", "number", "or", "alphanumeric", ")", ":", "type", "byteIter", ":", "str", ":", "return", ":", "Encoded", "SMS", "...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L573-L619
faucamp/python-gsmmodem
gsmmodem/pdu.py
encodeSemiOctets
def encodeSemiOctets(number): """ Semi-octet encoding algorithm (e.g. for phone numbers) :return: bytearray containing the encoded octets :rtype: bytearray """ if len(number) % 2 == 1: number = number + 'F' # append the "end" indicator octets = [int(number[i+1] + number[i], 16) ...
python
def encodeSemiOctets(number): """ Semi-octet encoding algorithm (e.g. for phone numbers) :return: bytearray containing the encoded octets :rtype: bytearray """ if len(number) % 2 == 1: number = number + 'F' # append the "end" indicator octets = [int(number[i+1] + number[i], 16) ...
[ "def", "encodeSemiOctets", "(", "number", ")", ":", "if", "len", "(", "number", ")", "%", "2", "==", "1", ":", "number", "=", "number", "+", "'F'", "# append the \"end\" indicator", "octets", "=", "[", "int", "(", "number", "[", "i", "+", "1", "]", "...
Semi-octet encoding algorithm (e.g. for phone numbers) :return: bytearray containing the encoded octets :rtype: bytearray
[ "Semi", "-", "octet", "encoding", "algorithm", "(", "e", ".", "g", ".", "for", "phone", "numbers", ")", ":", "return", ":", "bytearray", "containing", "the", "encoded", "octets", ":", "rtype", ":", "bytearray" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L621-L630
faucamp/python-gsmmodem
gsmmodem/pdu.py
decodeSemiOctets
def decodeSemiOctets(encodedNumber, numberOfOctets=None): """ Semi-octet decoding algorithm(e.g. for phone numbers) :param encodedNumber: The semi-octet-encoded telephone number (in bytearray format or hex string) :type encodedNumber: bytearray, str or iter(bytearray) :param numberOfOctets: The exp...
python
def decodeSemiOctets(encodedNumber, numberOfOctets=None): """ Semi-octet decoding algorithm(e.g. for phone numbers) :param encodedNumber: The semi-octet-encoded telephone number (in bytearray format or hex string) :type encodedNumber: bytearray, str or iter(bytearray) :param numberOfOctets: The exp...
[ "def", "decodeSemiOctets", "(", "encodedNumber", ",", "numberOfOctets", "=", "None", ")", ":", "number", "=", "[", "]", "if", "type", "(", "encodedNumber", ")", "in", "(", "str", ",", "bytes", ")", ":", "encodedNumber", "=", "bytearray", "(", "codecs", "...
Semi-octet decoding algorithm(e.g. for phone numbers) :param encodedNumber: The semi-octet-encoded telephone number (in bytearray format or hex string) :type encodedNumber: bytearray, str or iter(bytearray) :param numberOfOctets: The expected amount of octets after decoding (i.e. when to stop) :typ...
[ "Semi", "-", "octet", "decoding", "algorithm", "(", "e", ".", "g", ".", "for", "phone", "numbers", ")", ":", "param", "encodedNumber", ":", "The", "semi", "-", "octet", "-", "encoded", "telephone", "number", "(", "in", "bytearray", "format", "or", "hex",...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L632-L658
faucamp/python-gsmmodem
gsmmodem/pdu.py
encodeGsm7
def encodeGsm7(plaintext, discardInvalid=False): """ GSM-7 text encoding algorithm Encodes the specified text string into GSM-7 octets (characters). This method does not pack the characters into septets. :param text: the text string to encode :param discardInvalid: if True, characters that...
python
def encodeGsm7(plaintext, discardInvalid=False): """ GSM-7 text encoding algorithm Encodes the specified text string into GSM-7 octets (characters). This method does not pack the characters into septets. :param text: the text string to encode :param discardInvalid: if True, characters that...
[ "def", "encodeGsm7", "(", "plaintext", ",", "discardInvalid", "=", "False", ")", ":", "result", "=", "bytearray", "(", ")", "if", "PYTHON_VERSION", ">=", "3", ":", "plaintext", "=", "str", "(", "plaintext", ")", "for", "char", "in", "plaintext", ":", "id...
GSM-7 text encoding algorithm Encodes the specified text string into GSM-7 octets (characters). This method does not pack the characters into septets. :param text: the text string to encode :param discardInvalid: if True, characters that cannot be encoded will be silently discarded :...
[ "GSM", "-", "7", "text", "encoding", "algorithm", "Encodes", "the", "specified", "text", "string", "into", "GSM", "-", "7", "octets", "(", "characters", ")", ".", "This", "method", "does", "not", "pack", "the", "characters", "into", "septets", ".", ":", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L660-L686
faucamp/python-gsmmodem
gsmmodem/pdu.py
decodeGsm7
def decodeGsm7(encodedText): """ GSM-7 text decoding algorithm Decodes the specified GSM-7-encoded string into a plaintext string. :param encodedText: the text string to encode :type encodedText: bytearray or str :return: A string containing the decoded text :rtype: str """ ...
python
def decodeGsm7(encodedText): """ GSM-7 text decoding algorithm Decodes the specified GSM-7-encoded string into a plaintext string. :param encodedText: the text string to encode :type encodedText: bytearray or str :return: A string containing the decoded text :rtype: str """ ...
[ "def", "decodeGsm7", "(", "encodedText", ")", ":", "result", "=", "[", "]", "if", "type", "(", "encodedText", ")", "==", "str", ":", "encodedText", "=", "rawStrToByteArray", "(", "encodedText", ")", "#bytearray(encodedText)", "iterEncoded", "=", "iter", "(", ...
GSM-7 text decoding algorithm Decodes the specified GSM-7-encoded string into a plaintext string. :param encodedText: the text string to encode :type encodedText: bytearray or str :return: A string containing the decoded text :rtype: str
[ "GSM", "-", "7", "text", "decoding", "algorithm", "Decodes", "the", "specified", "GSM", "-", "7", "-", "encoded", "string", "into", "a", "plaintext", "string", ".", ":", "param", "encodedText", ":", "the", "text", "string", "to", "encode", ":", "type", "...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L688-L712
faucamp/python-gsmmodem
gsmmodem/pdu.py
packSeptets
def packSeptets(octets, padBits=0): """ Packs the specified octets into septets Typically the output of encodeGsm7 would be used as input to this function. The resulting bytearray contains the original GSM-7 characters packed into septets ready for transmission. :rtype: bytearray """ r...
python
def packSeptets(octets, padBits=0): """ Packs the specified octets into septets Typically the output of encodeGsm7 would be used as input to this function. The resulting bytearray contains the original GSM-7 characters packed into septets ready for transmission. :rtype: bytearray """ r...
[ "def", "packSeptets", "(", "octets", ",", "padBits", "=", "0", ")", ":", "result", "=", "bytearray", "(", ")", "if", "type", "(", "octets", ")", "==", "str", ":", "octets", "=", "iter", "(", "rawStrToByteArray", "(", "octets", ")", ")", "elif", "type...
Packs the specified octets into septets Typically the output of encodeGsm7 would be used as input to this function. The resulting bytearray contains the original GSM-7 characters packed into septets ready for transmission. :rtype: bytearray
[ "Packs", "the", "specified", "octets", "into", "septets", "Typically", "the", "output", "of", "encodeGsm7", "would", "be", "used", "as", "input", "to", "this", "function", ".", "The", "resulting", "bytearray", "contains", "the", "original", "GSM", "-", "7", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L714-L746
faucamp/python-gsmmodem
gsmmodem/pdu.py
unpackSeptets
def unpackSeptets(septets, numberOfSeptets=None, prevOctet=None, shift=7): """ Unpacks the specified septets into octets :param septets: Iterator or iterable containing the septets packed into octets :type septets: iter(bytearray), bytearray or str :param numberOfSeptets: The amount of septets to ...
python
def unpackSeptets(septets, numberOfSeptets=None, prevOctet=None, shift=7): """ Unpacks the specified septets into octets :param septets: Iterator or iterable containing the septets packed into octets :type septets: iter(bytearray), bytearray or str :param numberOfSeptets: The amount of septets to ...
[ "def", "unpackSeptets", "(", "septets", ",", "numberOfSeptets", "=", "None", ",", "prevOctet", "=", "None", ",", "shift", "=", "7", ")", ":", "result", "=", "bytearray", "(", ")", "if", "type", "(", "septets", ")", "==", "str", ":", "septets", "=", "...
Unpacks the specified septets into octets :param septets: Iterator or iterable containing the septets packed into octets :type septets: iter(bytearray), bytearray or str :param numberOfSeptets: The amount of septets to unpack (or None for all remaining in "septets") :type numberOfSeptets: int or N...
[ "Unpacks", "the", "specified", "septets", "into", "octets", ":", "param", "septets", ":", "Iterator", "or", "iterable", "containing", "the", "septets", "packed", "into", "octets", ":", "type", "septets", ":", "iter", "(", "bytearray", ")", "bytearray", "or", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L748-L793
faucamp/python-gsmmodem
gsmmodem/pdu.py
decodeUcs2
def decodeUcs2(byteIter, numBytes): """ Decodes UCS2-encoded text from the specified byte iterator, up to a maximum of numBytes """ userData = [] i = 0 try: while i < numBytes: userData.append(unichr((next(byteIter) << 8) | next(byteIter))) i += 2 except StopIteration...
python
def decodeUcs2(byteIter, numBytes): """ Decodes UCS2-encoded text from the specified byte iterator, up to a maximum of numBytes """ userData = [] i = 0 try: while i < numBytes: userData.append(unichr((next(byteIter) << 8) | next(byteIter))) i += 2 except StopIteration...
[ "def", "decodeUcs2", "(", "byteIter", ",", "numBytes", ")", ":", "userData", "=", "[", "]", "i", "=", "0", "try", ":", "while", "i", "<", "numBytes", ":", "userData", ".", "append", "(", "unichr", "(", "(", "next", "(", "byteIter", ")", "<<", "8", ...
Decodes UCS2-encoded text from the specified byte iterator, up to a maximum of numBytes
[ "Decodes", "UCS2", "-", "encoded", "text", "from", "the", "specified", "byte", "iterator", "up", "to", "a", "maximum", "of", "numBytes" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L795-L806
faucamp/python-gsmmodem
gsmmodem/pdu.py
encodeUcs2
def encodeUcs2(text): """ UCS2 text encoding algorithm Encodes the specified text string into UCS2-encoded bytes. :param text: the text string to encode :return: A bytearray containing the string encoded in UCS2 encoding :rtype: bytearray """ result = bytearray() for b in ...
python
def encodeUcs2(text): """ UCS2 text encoding algorithm Encodes the specified text string into UCS2-encoded bytes. :param text: the text string to encode :return: A bytearray containing the string encoded in UCS2 encoding :rtype: bytearray """ result = bytearray() for b in ...
[ "def", "encodeUcs2", "(", "text", ")", ":", "result", "=", "bytearray", "(", ")", "for", "b", "in", "map", "(", "ord", ",", "text", ")", ":", "result", ".", "append", "(", "b", ">>", "8", ")", "result", ".", "append", "(", "b", "&", "0xFF", ")"...
UCS2 text encoding algorithm Encodes the specified text string into UCS2-encoded bytes. :param text: the text string to encode :return: A bytearray containing the string encoded in UCS2 encoding :rtype: bytearray
[ "UCS2", "text", "encoding", "algorithm", "Encodes", "the", "specified", "text", "string", "into", "UCS2", "-", "encoded", "bytes", ".", ":", "param", "text", ":", "the", "text", "string", "to", "encode", ":", "return", ":", "A", "bytearray", "containing", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L808-L822
faucamp/python-gsmmodem
gsmmodem/pdu.py
InformationElement.decode
def decode(cls, byteIter): """ Decodes a single IE at the current position in the specified byte iterator :return: An InformationElement (or subclass) instance for the decoded IE :rtype: InformationElement, or subclass thereof """ iei = next(byteIter) ie...
python
def decode(cls, byteIter): """ Decodes a single IE at the current position in the specified byte iterator :return: An InformationElement (or subclass) instance for the decoded IE :rtype: InformationElement, or subclass thereof """ iei = next(byteIter) ie...
[ "def", "decode", "(", "cls", ",", "byteIter", ")", ":", "iei", "=", "next", "(", "byteIter", ")", "ieLen", "=", "next", "(", "byteIter", ")", "ieData", "=", "[", "]", "for", "i", "in", "xrange", "(", "ieLen", ")", ":", "ieData", ".", "append", "(...
Decodes a single IE at the current position in the specified byte iterator :return: An InformationElement (or subclass) instance for the decoded IE :rtype: InformationElement, or subclass thereof
[ "Decodes", "a", "single", "IE", "at", "the", "current", "position", "in", "the", "specified", "byte", "iterator", ":", "return", ":", "An", "InformationElement", "(", "or", "subclass", ")", "instance", "for", "the", "decoded", "IE", ":", "rtype", ":", "Inf...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L109-L121
faucamp/python-gsmmodem
gsmmodem/pdu.py
InformationElement.encode
def encode(self): """ Encodes this IE and returns the resulting bytes """ result = bytearray() result.append(self.id) result.append(self.dataLength) result.extend(self.data) return result
python
def encode(self): """ Encodes this IE and returns the resulting bytes """ result = bytearray() result.append(self.id) result.append(self.dataLength) result.extend(self.data) return result
[ "def", "encode", "(", "self", ")", ":", "result", "=", "bytearray", "(", ")", "result", ".", "append", "(", "self", ".", "id", ")", "result", ".", "append", "(", "self", ".", "dataLength", ")", "result", ".", "extend", "(", "self", ".", "data", ")"...
Encodes this IE and returns the resulting bytes
[ "Encodes", "this", "IE", "and", "returns", "the", "resulting", "bytes" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L123-L129
faucamp/python-gsmmodem
tools/sendsms.py
parseArgsPy26
def parseArgsPy26(): """ Argument parser for Python 2.6 """ from gsmtermlib.posoptparse import PosOptionParser, Option parser = PosOptionParser(description='Simple script for sending SMS messages') parser.add_option('-i', '--port', metavar='PORT', help='port to which the GSM modem is connected; a number...
python
def parseArgsPy26(): """ Argument parser for Python 2.6 """ from gsmtermlib.posoptparse import PosOptionParser, Option parser = PosOptionParser(description='Simple script for sending SMS messages') parser.add_option('-i', '--port', metavar='PORT', help='port to which the GSM modem is connected; a number...
[ "def", "parseArgsPy26", "(", ")", ":", "from", "gsmtermlib", ".", "posoptparse", "import", "PosOptionParser", ",", "Option", "parser", "=", "PosOptionParser", "(", "description", "=", "'Simple script for sending SMS messages'", ")", "parser", ".", "add_option", "(", ...
Argument parser for Python 2.6
[ "Argument", "parser", "for", "Python", "2", ".", "6" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/sendsms.py#L26-L40
faucamp/python-gsmmodem
gsmmodem/util.py
parseTextModeTimeStr
def parseTextModeTimeStr(timeStr): """ Parses the specified SMS text mode time string The time stamp format is "yy/MM/dd,hh:mm:ss±zz" (yy = year, MM = month, dd = day, hh = hour, mm = minute, ss = second, zz = time zone [Note: the unit of time zone is a quarter of an hour]) :param timeStr:...
python
def parseTextModeTimeStr(timeStr): """ Parses the specified SMS text mode time string The time stamp format is "yy/MM/dd,hh:mm:ss±zz" (yy = year, MM = month, dd = day, hh = hour, mm = minute, ss = second, zz = time zone [Note: the unit of time zone is a quarter of an hour]) :param timeStr:...
[ "def", "parseTextModeTimeStr", "(", "timeStr", ")", ":", "msgTime", "=", "timeStr", "[", ":", "-", "3", "]", "tzOffsetHours", "=", "int", "(", "int", "(", "timeStr", "[", "-", "3", ":", "]", ")", "*", "0.25", ")", "return", "datetime", ".", "strptime...
Parses the specified SMS text mode time string The time stamp format is "yy/MM/dd,hh:mm:ss±zz" (yy = year, MM = month, dd = day, hh = hour, mm = minute, ss = second, zz = time zone [Note: the unit of time zone is a quarter of an hour]) :param timeStr: The time string to parse :type timeStr...
[ "Parses", "the", "specified", "SMS", "text", "mode", "time", "string", "The", "time", "stamp", "format", "is", "yy", "/", "MM", "/", "dd", "hh", ":", "mm", ":", "ss±zz", "(", "yy", "=", "year", "MM", "=", "month", "dd", "=", "day", "hh", "=", "ho...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/util.py#L30-L45
faucamp/python-gsmmodem
gsmmodem/util.py
lineMatching
def lineMatching(regexStr, lines): """ Searches through the specified list of strings and returns the regular expression match for the first line that matches the specified regex string, or None if no match was found Note: if you have a pre-compiled regex pattern, use lineMatchingPattern() instead :t...
python
def lineMatching(regexStr, lines): """ Searches through the specified list of strings and returns the regular expression match for the first line that matches the specified regex string, or None if no match was found Note: if you have a pre-compiled regex pattern, use lineMatchingPattern() instead :t...
[ "def", "lineMatching", "(", "regexStr", ",", "lines", ")", ":", "regex", "=", "re", ".", "compile", "(", "regexStr", ")", "for", "line", "in", "lines", ":", "m", "=", "regex", ".", "match", "(", "line", ")", "if", "m", ":", "return", "m", "else", ...
Searches through the specified list of strings and returns the regular expression match for the first line that matches the specified regex string, or None if no match was found Note: if you have a pre-compiled regex pattern, use lineMatchingPattern() instead :type regexStr: Regular expression string to ...
[ "Searches", "through", "the", "specified", "list", "of", "strings", "and", "returns", "the", "regular", "expression", "match", "for", "the", "first", "line", "that", "matches", "the", "specified", "regex", "string", "or", "None", "if", "no", "match", "was", ...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/util.py#L57-L75
faucamp/python-gsmmodem
gsmmodem/util.py
lineMatchingPattern
def lineMatchingPattern(pattern, lines): """ Searches through the specified list of strings and returns the regular expression match for the first line that matches the specified pre-compiled regex pattern, or None if no match was found Note: if you are using a regex pattern string (i.e. not already compi...
python
def lineMatchingPattern(pattern, lines): """ Searches through the specified list of strings and returns the regular expression match for the first line that matches the specified pre-compiled regex pattern, or None if no match was found Note: if you are using a regex pattern string (i.e. not already compi...
[ "def", "lineMatchingPattern", "(", "pattern", ",", "lines", ")", ":", "for", "line", "in", "lines", ":", "m", "=", "pattern", ".", "match", "(", "line", ")", "if", "m", ":", "return", "m", "else", ":", "return", "None" ]
Searches through the specified list of strings and returns the regular expression match for the first line that matches the specified pre-compiled regex pattern, or None if no match was found Note: if you are using a regex pattern string (i.e. not already compiled), use lineMatching() instead :type patte...
[ "Searches", "through", "the", "specified", "list", "of", "strings", "and", "returns", "the", "regular", "expression", "match", "for", "the", "first", "line", "that", "matches", "the", "specified", "pre", "-", "compiled", "regex", "pattern", "or", "None", "if",...
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/util.py#L77-L94
faucamp/python-gsmmodem
gsmmodem/util.py
allLinesMatchingPattern
def allLinesMatchingPattern(pattern, lines): """ Like lineMatchingPattern, but returns all lines that match the specified pattern :type pattern: Compiled regular expression pattern to use :type lines: List of lines to search :return: list of re.Match objects for each line matched, or an empty list if ...
python
def allLinesMatchingPattern(pattern, lines): """ Like lineMatchingPattern, but returns all lines that match the specified pattern :type pattern: Compiled regular expression pattern to use :type lines: List of lines to search :return: list of re.Match objects for each line matched, or an empty list if ...
[ "def", "allLinesMatchingPattern", "(", "pattern", ",", "lines", ")", ":", "result", "=", "[", "]", "for", "line", "in", "lines", ":", "m", "=", "pattern", ".", "match", "(", "line", ")", "if", "m", ":", "result", ".", "append", "(", "m", ")", "retu...
Like lineMatchingPattern, but returns all lines that match the specified pattern :type pattern: Compiled regular expression pattern to use :type lines: List of lines to search :return: list of re.Match objects for each line matched, or an empty list if none matched :rtype: list
[ "Like", "lineMatchingPattern", "but", "returns", "all", "lines", "that", "match", "the", "specified", "pattern" ]
train
https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/util.py#L96-L110
n8henrie/pycookiecheat
src/pycookiecheat/pycookiecheat.py
clean
def clean(decrypted: bytes) -> str: r"""Strip padding from decrypted value. Remove number indicated by padding e.g. if last is '\x0e' then ord('\x0e') == 14, so take off 14. Args: decrypted: decrypted value Returns: Decrypted stripped of junk padding """ last = decrypted[-...
python
def clean(decrypted: bytes) -> str: r"""Strip padding from decrypted value. Remove number indicated by padding e.g. if last is '\x0e' then ord('\x0e') == 14, so take off 14. Args: decrypted: decrypted value Returns: Decrypted stripped of junk padding """ last = decrypted[-...
[ "def", "clean", "(", "decrypted", ":", "bytes", ")", "->", "str", ":", "last", "=", "decrypted", "[", "-", "1", "]", "if", "isinstance", "(", "last", ",", "int", ")", ":", "return", "decrypted", "[", ":", "-", "last", "]", ".", "decode", "(", "'u...
r"""Strip padding from decrypted value. Remove number indicated by padding e.g. if last is '\x0e' then ord('\x0e') == 14, so take off 14. Args: decrypted: decrypted value Returns: Decrypted stripped of junk padding
[ "r", "Strip", "padding", "from", "decrypted", "value", "." ]
train
https://github.com/n8henrie/pycookiecheat/blob/1e0ba783da31689f5b37f9706205ff366d72f03d/src/pycookiecheat/pycookiecheat.py#L26-L41
n8henrie/pycookiecheat
src/pycookiecheat/pycookiecheat.py
chrome_decrypt
def chrome_decrypt(encrypted_value: bytes, key: bytes, init_vector: bytes) \ -> str: """Decrypt Chrome/Chromium's encrypted cookies. Args: encrypted_value: Encrypted cookie from Chrome/Chromium's cookie file key: Key to decrypt encrypted_value init_vector: Initialization vector ...
python
def chrome_decrypt(encrypted_value: bytes, key: bytes, init_vector: bytes) \ -> str: """Decrypt Chrome/Chromium's encrypted cookies. Args: encrypted_value: Encrypted cookie from Chrome/Chromium's cookie file key: Key to decrypt encrypted_value init_vector: Initialization vector ...
[ "def", "chrome_decrypt", "(", "encrypted_value", ":", "bytes", ",", "key", ":", "bytes", ",", "init_vector", ":", "bytes", ")", "->", "str", ":", "# Encrypted cookies should be prefixed with 'v10' or 'v11' according to the", "# Chromium code. Strip it off.", "encrypted_value"...
Decrypt Chrome/Chromium's encrypted cookies. Args: encrypted_value: Encrypted cookie from Chrome/Chromium's cookie file key: Key to decrypt encrypted_value init_vector: Initialization vector for decrypting encrypted_value Returns: Decrypted value of encrypted_value
[ "Decrypt", "Chrome", "/", "Chromium", "s", "encrypted", "cookies", "." ]
train
https://github.com/n8henrie/pycookiecheat/blob/1e0ba783da31689f5b37f9706205ff366d72f03d/src/pycookiecheat/pycookiecheat.py#L44-L63
n8henrie/pycookiecheat
src/pycookiecheat/pycookiecheat.py
get_osx_config
def get_osx_config(browser: str) -> dict: """Get settings for getting Chrome/Chromium cookies on OSX. Args: browser: Either "Chrome" or "Chromium" Returns: Config dictionary for Chrome/Chromium cookie decryption """ # Verify supported browser, fail early otherwise if browser.lo...
python
def get_osx_config(browser: str) -> dict: """Get settings for getting Chrome/Chromium cookies on OSX. Args: browser: Either "Chrome" or "Chromium" Returns: Config dictionary for Chrome/Chromium cookie decryption """ # Verify supported browser, fail early otherwise if browser.lo...
[ "def", "get_osx_config", "(", "browser", ":", "str", ")", "->", "dict", ":", "# Verify supported browser, fail early otherwise", "if", "browser", ".", "lower", "(", ")", "==", "'chrome'", ":", "cookie_file", "=", "(", "'~/Library/Application Support/Google/Chrome/Defaul...
Get settings for getting Chrome/Chromium cookies on OSX. Args: browser: Either "Chrome" or "Chromium" Returns: Config dictionary for Chrome/Chromium cookie decryption
[ "Get", "settings", "for", "getting", "Chrome", "/", "Chromium", "cookies", "on", "OSX", "." ]
train
https://github.com/n8henrie/pycookiecheat/blob/1e0ba783da31689f5b37f9706205ff366d72f03d/src/pycookiecheat/pycookiecheat.py#L66-L90
n8henrie/pycookiecheat
src/pycookiecheat/pycookiecheat.py
get_linux_config
def get_linux_config(browser: str) -> dict: """Get the settings for Chrome/Chromium cookies on Linux. Args: browser: Either "Chrome" or "Chromium" Returns: Config dictionary for Chrome/Chromium cookie decryption """ # Verify supported browser, fail early otherwise if browser.lo...
python
def get_linux_config(browser: str) -> dict: """Get the settings for Chrome/Chromium cookies on Linux. Args: browser: Either "Chrome" or "Chromium" Returns: Config dictionary for Chrome/Chromium cookie decryption """ # Verify supported browser, fail early otherwise if browser.lo...
[ "def", "get_linux_config", "(", "browser", ":", "str", ")", "->", "dict", ":", "# Verify supported browser, fail early otherwise", "if", "browser", ".", "lower", "(", ")", "==", "'chrome'", ":", "cookie_file", "=", "'~/.config/google-chrome/Default/Cookies'", "elif", ...
Get the settings for Chrome/Chromium cookies on Linux. Args: browser: Either "Chrome" or "Chromium" Returns: Config dictionary for Chrome/Chromium cookie decryption
[ "Get", "the", "settings", "for", "Chrome", "/", "Chromium", "cookies", "on", "Linux", "." ]
train
https://github.com/n8henrie/pycookiecheat/blob/1e0ba783da31689f5b37f9706205ff366d72f03d/src/pycookiecheat/pycookiecheat.py#L93-L147
n8henrie/pycookiecheat
src/pycookiecheat/pycookiecheat.py
chrome_cookies
def chrome_cookies( url: str, cookie_file: str = None, browser: str = "Chrome", curl_cookie_file: str = None, ) -> dict: """Retrieve cookies from Chrome/Chromium on OSX or Linux. Args: url: Domain from which to retrieve cookies, starting with http(s) cook...
python
def chrome_cookies( url: str, cookie_file: str = None, browser: str = "Chrome", curl_cookie_file: str = None, ) -> dict: """Retrieve cookies from Chrome/Chromium on OSX or Linux. Args: url: Domain from which to retrieve cookies, starting with http(s) cook...
[ "def", "chrome_cookies", "(", "url", ":", "str", ",", "cookie_file", ":", "str", "=", "None", ",", "browser", ":", "str", "=", "\"Chrome\"", ",", "curl_cookie_file", ":", "str", "=", "None", ",", ")", "->", "dict", ":", "# If running Chrome on OSX", "if", ...
Retrieve cookies from Chrome/Chromium on OSX or Linux. Args: url: Domain from which to retrieve cookies, starting with http(s) cookie_file: Path to alternate file to search for cookies browser: Name of the browser's cookies to read ('Chrome' or 'Chromium') curl_cookie_file: Path to ...
[ "Retrieve", "cookies", "from", "Chrome", "/", "Chromium", "on", "OSX", "or", "Linux", "." ]
train
https://github.com/n8henrie/pycookiecheat/blob/1e0ba783da31689f5b37f9706205ff366d72f03d/src/pycookiecheat/pycookiecheat.py#L150-L244
n8henrie/pycookiecheat
src/pycookiecheat/pycookiecheat.py
generate_host_keys
def generate_host_keys(hostname: str) -> Iterator[str]: """Yield Chrome/Chromium keys for `hostname`, from least to most specific. Given a hostname like foo.example.com, this yields the key sequence: example.com .example.com foo.example.com .foo.example.com """ labels = hostname.split...
python
def generate_host_keys(hostname: str) -> Iterator[str]: """Yield Chrome/Chromium keys for `hostname`, from least to most specific. Given a hostname like foo.example.com, this yields the key sequence: example.com .example.com foo.example.com .foo.example.com """ labels = hostname.split...
[ "def", "generate_host_keys", "(", "hostname", ":", "str", ")", "->", "Iterator", "[", "str", "]", ":", "labels", "=", "hostname", ".", "split", "(", "'.'", ")", "for", "i", "in", "range", "(", "2", ",", "len", "(", "labels", ")", "+", "1", ")", "...
Yield Chrome/Chromium keys for `hostname`, from least to most specific. Given a hostname like foo.example.com, this yields the key sequence: example.com .example.com foo.example.com .foo.example.com
[ "Yield", "Chrome", "/", "Chromium", "keys", "for", "hostname", "from", "least", "to", "most", "specific", "." ]
train
https://github.com/n8henrie/pycookiecheat/blob/1e0ba783da31689f5b37f9706205ff366d72f03d/src/pycookiecheat/pycookiecheat.py#L247-L262
pyhys/minimalmodbus
omegacn7500.py
_checkSetpointValue
def _checkSetpointValue( setpointvalue, maxvalue ): """Check that the given setpointvalue is valid. Args: * setpointvalue (numerical): The setpoint value to be checked. Must be positive. * maxvalue (numerical): Upper limit for setpoint value. Must be positive. Raises: ...
python
def _checkSetpointValue( setpointvalue, maxvalue ): """Check that the given setpointvalue is valid. Args: * setpointvalue (numerical): The setpoint value to be checked. Must be positive. * maxvalue (numerical): Upper limit for setpoint value. Must be positive. Raises: ...
[ "def", "_checkSetpointValue", "(", "setpointvalue", ",", "maxvalue", ")", ":", "if", "maxvalue", "is", "None", ":", "raise", "TypeError", "(", "'The maxvalue (for the setpoint) must not be None!'", ")", "minimalmodbus", ".", "_checkNumerical", "(", "setpointvalue", ",",...
Check that the given setpointvalue is valid. Args: * setpointvalue (numerical): The setpoint value to be checked. Must be positive. * maxvalue (numerical): Upper limit for setpoint value. Must be positive. Raises: TypeError, ValueError
[ "Check", "that", "the", "given", "setpointvalue", "is", "valid", ".", "Args", ":", "*", "setpointvalue", "(", "numerical", ")", ":", "The", "setpoint", "value", "to", "be", "checked", ".", "Must", "be", "positive", ".", "*", "maxvalue", "(", "numerical", ...
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L464-L477
pyhys/minimalmodbus
omegacn7500.py
_checkTimeValue
def _checkTimeValue( timevalue, maxvalue ): """Check that the given timevalue is valid. Args: * timevalue (numerical): The time value to be checked. Must be positive. * maxvalue (numerical): Upper limit for time value. Must be positive. Raises: TypeError, ValueError ...
python
def _checkTimeValue( timevalue, maxvalue ): """Check that the given timevalue is valid. Args: * timevalue (numerical): The time value to be checked. Must be positive. * maxvalue (numerical): Upper limit for time value. Must be positive. Raises: TypeError, ValueError ...
[ "def", "_checkTimeValue", "(", "timevalue", ",", "maxvalue", ")", ":", "if", "maxvalue", "is", "None", ":", "raise", "TypeError", "(", "'The maxvalue (for the time value) must not be None!'", ")", "minimalmodbus", ".", "_checkNumerical", "(", "timevalue", ",", "minval...
Check that the given timevalue is valid. Args: * timevalue (numerical): The time value to be checked. Must be positive. * maxvalue (numerical): Upper limit for time value. Must be positive. Raises: TypeError, ValueError
[ "Check", "that", "the", "given", "timevalue", "is", "valid", ".", "Args", ":", "*", "timevalue", "(", "numerical", ")", ":", "The", "time", "value", "to", "be", "checked", ".", "Must", "be", "positive", ".", "*", "maxvalue", "(", "numerical", ")", ":",...
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L480-L493
pyhys/minimalmodbus
omegacn7500.py
_calculateRegisterAddress
def _calculateRegisterAddress( registertype, patternnumber, stepnumber = None): """Calculate the register address for pattern related parameters. Args: * registertype (string): The type of parameter, for example 'cycles'. Allowed are the keys from :data:`REGISTER_START`. * patter...
python
def _calculateRegisterAddress( registertype, patternnumber, stepnumber = None): """Calculate the register address for pattern related parameters. Args: * registertype (string): The type of parameter, for example 'cycles'. Allowed are the keys from :data:`REGISTER_START`. * patter...
[ "def", "_calculateRegisterAddress", "(", "registertype", ",", "patternnumber", ",", "stepnumber", "=", "None", ")", ":", "if", "stepnumber", "is", "None", ":", "stepnumber", "=", "0", "# Argument checking", "_checkPatternNumber", "(", "patternnumber", ")", "_checkSt...
Calculate the register address for pattern related parameters. Args: * registertype (string): The type of parameter, for example 'cycles'. Allowed are the keys from :data:`REGISTER_START`. * patternnumber (int): The pattern number. * stepnumber (int): The step number. Use Non...
[ "Calculate", "the", "register", "address", "for", "pattern", "related", "parameters", ".", "Args", ":", "*", "registertype", "(", "string", ")", ":", "The", "type", "of", "parameter", "for", "example", "cycles", ".", "Allowed", "are", "the", "keys", "from", ...
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L496-L528
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.set_setpoint
def set_setpoint(self, setpointvalue): """Set the setpoint. Args: setpointvalue (float): Setpoint [most often in degrees] """ _checkSetpointValue( setpointvalue, self.setpoint_max ) self.write_register( 4097, setpointvalue, 1)
python
def set_setpoint(self, setpointvalue): """Set the setpoint. Args: setpointvalue (float): Setpoint [most often in degrees] """ _checkSetpointValue( setpointvalue, self.setpoint_max ) self.write_register( 4097, setpointvalue, 1)
[ "def", "set_setpoint", "(", "self", ",", "setpointvalue", ")", ":", "_checkSetpointValue", "(", "setpointvalue", ",", "self", ".", "setpoint_max", ")", "self", ".", "write_register", "(", "4097", ",", "setpointvalue", ",", "1", ")" ]
Set the setpoint. Args: setpointvalue (float): Setpoint [most often in degrees]
[ "Set", "the", "setpoint", ".", "Args", ":", "setpointvalue", "(", "float", ")", ":", "Setpoint", "[", "most", "often", "in", "degrees", "]" ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L160-L168
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.get_control_mode
def get_control_mode(self): """Get the name of the current operation mode. Returns: A string decribing the controlmode. The returned string is one of the items in :data:`CONTROL_MODES`. """ mode_value = self.read_register(4101) t...
python
def get_control_mode(self): """Get the name of the current operation mode. Returns: A string decribing the controlmode. The returned string is one of the items in :data:`CONTROL_MODES`. """ mode_value = self.read_register(4101) t...
[ "def", "get_control_mode", "(", "self", ")", ":", "mode_value", "=", "self", ".", "read_register", "(", "4101", ")", "try", ":", "return", "CONTROL_MODES", "[", "mode_value", "]", "except", "KeyError", ":", "raise", "ValueError", "(", "'Could not parse the contr...
Get the name of the current operation mode. Returns: A string decribing the controlmode. The returned string is one of the items in :data:`CONTROL_MODES`.
[ "Get", "the", "name", "of", "the", "current", "operation", "mode", ".", "Returns", ":", "A", "string", "decribing", "the", "controlmode", ".", "The", "returned", "string", "is", "one", "of", "the", "items", "in", ":", "data", ":", "CONTROL_MODES", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L173-L187
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.set_control_mode
def set_control_mode(self, modevalue): """Set the control method using the corresponding integer value. Args: modevalue(int): 0-3 The modevalue is one of the keys in :data:`CONTROL_MODES`. """ minimalmodbus._checkInt(modevalue, minval...
python
def set_control_mode(self, modevalue): """Set the control method using the corresponding integer value. Args: modevalue(int): 0-3 The modevalue is one of the keys in :data:`CONTROL_MODES`. """ minimalmodbus._checkInt(modevalue, minval...
[ "def", "set_control_mode", "(", "self", ",", "modevalue", ")", ":", "minimalmodbus", ".", "_checkInt", "(", "modevalue", ",", "minvalue", "=", "0", ",", "maxvalue", "=", "3", ",", "description", "=", "'control mode'", ")", "self", ".", "write_register", "(",...
Set the control method using the corresponding integer value. Args: modevalue(int): 0-3 The modevalue is one of the keys in :data:`CONTROL_MODES`.
[ "Set", "the", "control", "method", "using", "the", "corresponding", "integer", "value", ".", "Args", ":", "modevalue", "(", "int", ")", ":", "0", "-", "3", "The", "modevalue", "is", "one", "of", "the", "keys", "in", ":", "data", ":", "CONTROL_MODES", "...
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L190-L199
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.set_pattern_step_setpoint
def set_pattern_step_setpoint(self, patternnumber, stepnumber, setpointvalue): """Set the setpoint value for a step. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 * setpointvalue (float): Setpoint value """ _checkPatternNumber(patte...
python
def set_pattern_step_setpoint(self, patternnumber, stepnumber, setpointvalue): """Set the setpoint value for a step. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 * setpointvalue (float): Setpoint value """ _checkPatternNumber(patte...
[ "def", "set_pattern_step_setpoint", "(", "self", ",", "patternnumber", ",", "stepnumber", ",", "setpointvalue", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "_checkStepNumber", "(", "stepnumber", ")", "_checkSetpointValue", "(", "setpointvalue", ",", "s...
Set the setpoint value for a step. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 * setpointvalue (float): Setpoint value
[ "Set", "the", "setpoint", "value", "for", "a", "step", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L237-L250
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.get_pattern_step_time
def get_pattern_step_time(self, patternnumber, stepnumber): """Get the step time. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 Returns: The step time (int??). """ _checkPatternNumber(pa...
python
def get_pattern_step_time(self, patternnumber, stepnumber): """Get the step time. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 Returns: The step time (int??). """ _checkPatternNumber(pa...
[ "def", "get_pattern_step_time", "(", "self", ",", "patternnumber", ",", "stepnumber", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "_checkStepNumber", "(", "stepnumber", ")", "address", "=", "_calculateRegisterAddress", "(", "'time'", ",", "patternnumbe...
Get the step time. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 Returns: The step time (int??).
[ "Get", "the", "step", "time", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L253-L268
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.set_pattern_step_time
def set_pattern_step_time(self, patternnumber, stepnumber, timevalue): """Set the step time. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 * timevalue (integer??): 0-900 """ _checkPatternNumber(patternnumber) _checkStepNumbe...
python
def set_pattern_step_time(self, patternnumber, stepnumber, timevalue): """Set the step time. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 * timevalue (integer??): 0-900 """ _checkPatternNumber(patternnumber) _checkStepNumbe...
[ "def", "set_pattern_step_time", "(", "self", ",", "patternnumber", ",", "stepnumber", ",", "timevalue", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "_checkStepNumber", "(", "stepnumber", ")", "_checkTimeValue", "(", "timevalue", ",", "self", ".", "...
Set the step time. Args: * patternnumber (integer): 0-7 * stepnumber (integer): 0-7 * timevalue (integer??): 0-900
[ "Set", "the", "step", "time", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L271-L284
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.get_pattern_actual_step
def get_pattern_actual_step(self, patternnumber): """Get the 'actual step' parameter for a given pattern. Args: patternnumber (integer): 0-7 Returns: The 'actual step' parameter (int). """ _checkPatternNumber(patternnumber) ...
python
def get_pattern_actual_step(self, patternnumber): """Get the 'actual step' parameter for a given pattern. Args: patternnumber (integer): 0-7 Returns: The 'actual step' parameter (int). """ _checkPatternNumber(patternnumber) ...
[ "def", "get_pattern_actual_step", "(", "self", ",", "patternnumber", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "address", "=", "_calculateRegisterAddress", "(", "'actualstep'", ",", "patternnumber", ")", "return", "self", ".", "read_register", "(", ...
Get the 'actual step' parameter for a given pattern. Args: patternnumber (integer): 0-7 Returns: The 'actual step' parameter (int).
[ "Get", "the", "actual", "step", "parameter", "for", "a", "given", "pattern", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L287-L300
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.set_pattern_actual_step
def set_pattern_actual_step(self, patternnumber, value): """Set the 'actual step' parameter for a given pattern. Args: * patternnumber (integer): 0-7 * value (integer): 0-7 """ _checkPatternNumber(patternnumber) _checkStepNumber(value) ad...
python
def set_pattern_actual_step(self, patternnumber, value): """Set the 'actual step' parameter for a given pattern. Args: * patternnumber (integer): 0-7 * value (integer): 0-7 """ _checkPatternNumber(patternnumber) _checkStepNumber(value) ad...
[ "def", "set_pattern_actual_step", "(", "self", ",", "patternnumber", ",", "value", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "_checkStepNumber", "(", "value", ")", "address", "=", "_calculateRegisterAddress", "(", "'actualstep'", ",", "patternnumber"...
Set the 'actual step' parameter for a given pattern. Args: * patternnumber (integer): 0-7 * value (integer): 0-7
[ "Set", "the", "actual", "step", "parameter", "for", "a", "given", "pattern", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L303-L314
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.get_pattern_additional_cycles
def get_pattern_additional_cycles(self, patternnumber): """Get the number of additional cycles for a given pattern. Args: patternnumber (integer): 0-7 Returns: The number of additional cycles (int). """ _checkPatternN...
python
def get_pattern_additional_cycles(self, patternnumber): """Get the number of additional cycles for a given pattern. Args: patternnumber (integer): 0-7 Returns: The number of additional cycles (int). """ _checkPatternN...
[ "def", "get_pattern_additional_cycles", "(", "self", ",", "patternnumber", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "address", "=", "_calculateRegisterAddress", "(", "'cycles'", ",", "patternnumber", ")", "return", "self", ".", "read_register", "(",...
Get the number of additional cycles for a given pattern. Args: patternnumber (integer): 0-7 Returns: The number of additional cycles (int).
[ "Get", "the", "number", "of", "additional", "cycles", "for", "a", "given", "pattern", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L317-L330
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.set_pattern_additional_cycles
def set_pattern_additional_cycles(self, patternnumber, value): """Set the number of additional cycles for a given pattern. Args: * patternnumber (integer): 0-7 * value (integer): 0-99 """ _checkPatternNumber(patternnumber) minimalmodbus._checkInt(value, m...
python
def set_pattern_additional_cycles(self, patternnumber, value): """Set the number of additional cycles for a given pattern. Args: * patternnumber (integer): 0-7 * value (integer): 0-99 """ _checkPatternNumber(patternnumber) minimalmodbus._checkInt(value, m...
[ "def", "set_pattern_additional_cycles", "(", "self", ",", "patternnumber", ",", "value", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "minimalmodbus", ".", "_checkInt", "(", "value", ",", "minvalue", "=", "0", ",", "maxvalue", "=", "99", ",", "d...
Set the number of additional cycles for a given pattern. Args: * patternnumber (integer): 0-7 * value (integer): 0-99
[ "Set", "the", "number", "of", "additional", "cycles", "for", "a", "given", "pattern", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L333-L344
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.get_pattern_link_topattern
def get_pattern_link_topattern(self, patternnumber): """Get the 'linked pattern' value for a given pattern. Args: patternnumber (integer): From 0-7 Returns: The 'linked pattern' value (int). """ _checkPatternNumber(patternnumber) add...
python
def get_pattern_link_topattern(self, patternnumber): """Get the 'linked pattern' value for a given pattern. Args: patternnumber (integer): From 0-7 Returns: The 'linked pattern' value (int). """ _checkPatternNumber(patternnumber) add...
[ "def", "get_pattern_link_topattern", "(", "self", ",", "patternnumber", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "address", "=", "_calculateRegisterAddress", "(", "'linkpattern'", ",", "patternnumber", ")", "return", "self", ".", "read_register", "(...
Get the 'linked pattern' value for a given pattern. Args: patternnumber (integer): From 0-7 Returns: The 'linked pattern' value (int).
[ "Get", "the", "linked", "pattern", "value", "for", "a", "given", "pattern", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L347-L359
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.get_all_pattern_variables
def get_all_pattern_variables(self, patternnumber): """Get all variables for a given pattern at one time. Args: patternnumber (integer): 0-7 Returns: A descriptive multiline string. """ _checkPatternNumber(patternnumber) ...
python
def get_all_pattern_variables(self, patternnumber): """Get all variables for a given pattern at one time. Args: patternnumber (integer): 0-7 Returns: A descriptive multiline string. """ _checkPatternNumber(patternnumber) ...
[ "def", "get_all_pattern_variables", "(", "self", ",", "patternnumber", ")", ":", "_checkPatternNumber", "(", "patternnumber", ")", "outputstring", "=", "''", "for", "stepnumber", "in", "range", "(", "8", ")", ":", "outputstring", "+=", "'SP{0}: {1} Time{0}: {2}\\n'...
Get all variables for a given pattern at one time. Args: patternnumber (integer): 0-7 Returns: A descriptive multiline string.
[ "Get", "all", "variables", "for", "a", "given", "pattern", "at", "one", "time", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L376-L398
pyhys/minimalmodbus
omegacn7500.py
OmegaCN7500.set_all_pattern_variables
def set_all_pattern_variables(self, patternnumber, \ sp0, ti0, sp1, ti1, sp2, ti2, sp3, ti3, sp4, ti4, sp5, ti5, sp6, ti6, sp7, ti7, \ actual_step, additional_cycles, link_pattern): """Set all variables for a given pattern at one time. Args: * patternnumber (integer): 0-7 ...
python
def set_all_pattern_variables(self, patternnumber, \ sp0, ti0, sp1, ti1, sp2, ti2, sp3, ti3, sp4, ti4, sp5, ti5, sp6, ti6, sp7, ti7, \ actual_step, additional_cycles, link_pattern): """Set all variables for a given pattern at one time. Args: * patternnumber (integer): 0-7 ...
[ "def", "set_all_pattern_variables", "(", "self", ",", "patternnumber", ",", "sp0", ",", "ti0", ",", "sp1", ",", "ti1", ",", "sp2", ",", "ti2", ",", "sp3", ",", "ti3", ",", "sp4", ",", "ti4", ",", "sp5", ",", "ti5", ",", "sp6", ",", "ti6", ",", "s...
Set all variables for a given pattern at one time. Args: * patternnumber (integer): 0-7 * sp[*n*] (float): setpoint value for step *n* * ti[*n*] (integer??): step time for step *n*, 0-900 * actual_step (int): ? * additional_cycles(int): ? ...
[ "Set", "all", "variables", "for", "a", "given", "pattern", "at", "one", "time", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L401-L435
pyhys/minimalmodbus
dummy_serial.py
Serial.open
def open(self): """Open a (previously initialized) port on dummy_serial.""" if VERBOSE: _print_out('\nDummy_serial: Opening port\n') if self._isOpen: raise IOError('Dummy_serial: The port is already open') self._isOpen = True self.port = self...
python
def open(self): """Open a (previously initialized) port on dummy_serial.""" if VERBOSE: _print_out('\nDummy_serial: Opening port\n') if self._isOpen: raise IOError('Dummy_serial: The port is already open') self._isOpen = True self.port = self...
[ "def", "open", "(", "self", ")", ":", "if", "VERBOSE", ":", "_print_out", "(", "'\\nDummy_serial: Opening port\\n'", ")", "if", "self", ".", "_isOpen", ":", "raise", "IOError", "(", "'Dummy_serial: The port is already open'", ")", "self", ".", "_isOpen", "=", "T...
Open a (previously initialized) port on dummy_serial.
[ "Open", "a", "(", "previously", "initialized", ")", "port", "on", "dummy_serial", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L118-L127
pyhys/minimalmodbus
dummy_serial.py
Serial.close
def close(self): """Close a port on dummy_serial.""" if VERBOSE: _print_out('\nDummy_serial: Closing port\n') if not self._isOpen: raise IOError('Dummy_serial: The port is already closed') self._isOpen = False self.port = None
python
def close(self): """Close a port on dummy_serial.""" if VERBOSE: _print_out('\nDummy_serial: Closing port\n') if not self._isOpen: raise IOError('Dummy_serial: The port is already closed') self._isOpen = False self.port = None
[ "def", "close", "(", "self", ")", ":", "if", "VERBOSE", ":", "_print_out", "(", "'\\nDummy_serial: Closing port\\n'", ")", "if", "not", "self", ".", "_isOpen", ":", "raise", "IOError", "(", "'Dummy_serial: The port is already closed'", ")", "self", ".", "_isOpen",...
Close a port on dummy_serial.
[ "Close", "a", "port", "on", "dummy_serial", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L129-L138
pyhys/minimalmodbus
dummy_serial.py
Serial.write
def write(self, inputdata): """Write to a port on dummy_serial. Args: inputdata (string/bytes): data for sending to the port on dummy_serial. Will affect the response for subsequent read operations. Note that for Python2, the inputdata should be a **string**. For Pytho...
python
def write(self, inputdata): """Write to a port on dummy_serial. Args: inputdata (string/bytes): data for sending to the port on dummy_serial. Will affect the response for subsequent read operations. Note that for Python2, the inputdata should be a **string**. For Pytho...
[ "def", "write", "(", "self", ",", "inputdata", ")", ":", "if", "VERBOSE", ":", "_print_out", "(", "'\\nDummy_serial: Writing to port. Given:'", "+", "repr", "(", "inputdata", ")", "+", "'\\n'", ")", "if", "sys", ".", "version_info", "[", "0", "]", ">", "2"...
Write to a port on dummy_serial. Args: inputdata (string/bytes): data for sending to the port on dummy_serial. Will affect the response for subsequent read operations. Note that for Python2, the inputdata should be a **string**. For Python3 it should be of type **bytes**.
[ "Write", "to", "a", "port", "on", "dummy_serial", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L141-L169
pyhys/minimalmodbus
dummy_serial.py
Serial.read
def read(self, numberOfBytes): """Read from a port on dummy_serial. The response is dependent on what was written last to the port on dummy_serial, and what is defined in the :data:`RESPONSES` dictionary. Args: numberOfBytes (int): For compability with the real function. ...
python
def read(self, numberOfBytes): """Read from a port on dummy_serial. The response is dependent on what was written last to the port on dummy_serial, and what is defined in the :data:`RESPONSES` dictionary. Args: numberOfBytes (int): For compability with the real function. ...
[ "def", "read", "(", "self", ",", "numberOfBytes", ")", ":", "if", "VERBOSE", ":", "_print_out", "(", "'\\nDummy_serial: Reading from port (max length {!r} bytes)'", ".", "format", "(", "numberOfBytes", ")", ")", "if", "numberOfBytes", "<", "0", ":", "raise", "IOEr...
Read from a port on dummy_serial. The response is dependent on what was written last to the port on dummy_serial, and what is defined in the :data:`RESPONSES` dictionary. Args: numberOfBytes (int): For compability with the real function. Returns a **string** for Python2 a...
[ "Read", "from", "a", "port", "on", "dummy_serial", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L172-L227
pyhys/minimalmodbus
minimalmodbus.py
_embedPayload
def _embedPayload(slaveaddress, mode, functioncode, payloaddata): """Build a request from the slaveaddress, the function code and the payload data. Args: * slaveaddress (int): The address of the slave. * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII) * functioncode (int): ...
python
def _embedPayload(slaveaddress, mode, functioncode, payloaddata): """Build a request from the slaveaddress, the function code and the payload data. Args: * slaveaddress (int): The address of the slave. * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII) * functioncode (int): ...
[ "def", "_embedPayload", "(", "slaveaddress", ",", "mode", ",", "functioncode", ",", "payloaddata", ")", ":", "_checkSlaveaddress", "(", "slaveaddress", ")", "_checkMode", "(", "mode", ")", "_checkFunctioncode", "(", "functioncode", ",", "None", ")", "_checkString"...
Build a request from the slaveaddress, the function code and the payload data. Args: * slaveaddress (int): The address of the slave. * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII) * functioncode (int): The function code for the command to be performed. Can for example be 16 ...
[ "Build", "a", "request", "from", "the", "slaveaddress", "the", "function", "code", "and", "the", "payload", "data", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L939-L977
pyhys/minimalmodbus
minimalmodbus.py
_extractPayload
def _extractPayload(response, slaveaddress, mode, functioncode): """Extract the payload data part from the slave's response. Args: * response (str): The raw response byte string from the slave. * slaveaddress (int): The adress of the slave. Used here for error checking only. * mode (str...
python
def _extractPayload(response, slaveaddress, mode, functioncode): """Extract the payload data part from the slave's response. Args: * response (str): The raw response byte string from the slave. * slaveaddress (int): The adress of the slave. Used here for error checking only. * mode (str...
[ "def", "_extractPayload", "(", "response", ",", "slaveaddress", ",", "mode", ",", "functioncode", ")", ":", "BYTEPOSITION_FOR_ASCII_HEADER", "=", "0", "# Relative to plain response", "BYTEPOSITION_FOR_SLAVEADDRESS", "=", "0", "# Relative to (stripped) response", "BYTEPOSITION...
Extract the payload data part from the slave's response. Args: * response (str): The raw response byte string from the slave. * slaveaddress (int): The adress of the slave. Used here for error checking only. * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII) * functionco...
[ "Extract", "the", "payload", "data", "part", "from", "the", "slave", "s", "response", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L980-L1103
pyhys/minimalmodbus
minimalmodbus.py
_predictResponseSize
def _predictResponseSize(mode, functioncode, payloadToSlave): """Calculate the number of bytes that should be received from the slave. Args: * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII) * functioncode (int): Modbus function code. * payloadToSlave (str): The raw request that is ...
python
def _predictResponseSize(mode, functioncode, payloadToSlave): """Calculate the number of bytes that should be received from the slave. Args: * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII) * functioncode (int): Modbus function code. * payloadToSlave (str): The raw request that is ...
[ "def", "_predictResponseSize", "(", "mode", ",", "functioncode", ",", "payloadToSlave", ")", ":", "MIN_PAYLOAD_LENGTH", "=", "4", "# For implemented functioncodes here", "BYTERANGE_FOR_GIVEN_SIZE", "=", "slice", "(", "2", ",", "4", ")", "# Within the payload", "NUMBER_O...
Calculate the number of bytes that should be received from the slave. Args: * mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII) * functioncode (int): Modbus function code. * payloadToSlave (str): The raw request that is to be sent to the slave (not hex encoded string) Returns: ...
[ "Calculate", "the", "number", "of", "bytes", "that", "should", "be", "received", "from", "the", "slave", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1110-L1172
pyhys/minimalmodbus
minimalmodbus.py
_calculate_minimum_silent_period
def _calculate_minimum_silent_period(baudrate): """Calculate the silent period length to comply with the 3.5 character silence between messages. Args: baudrate (numerical): The baudrate for the serial port Returns: The number of seconds (float) that should pass between each message on the ...
python
def _calculate_minimum_silent_period(baudrate): """Calculate the silent period length to comply with the 3.5 character silence between messages. Args: baudrate (numerical): The baudrate for the serial port Returns: The number of seconds (float) that should pass between each message on the ...
[ "def", "_calculate_minimum_silent_period", "(", "baudrate", ")", ":", "_checkNumerical", "(", "baudrate", ",", "minvalue", "=", "1", ",", "description", "=", "'baudrate'", ")", "# Avoid division by zero", "BITTIMES_PER_CHARACTERTIME", "=", "11", "MINIMUM_SILENT_CHARACTERT...
Calculate the silent period length to comply with the 3.5 character silence between messages. Args: baudrate (numerical): The baudrate for the serial port Returns: The number of seconds (float) that should pass between each message on the bus. Raises: ValueError, TypeError.
[ "Calculate", "the", "silent", "period", "length", "to", "comply", "with", "the", "3", ".", "5", "character", "silence", "between", "messages", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1175-L1194
pyhys/minimalmodbus
minimalmodbus.py
_numToTwoByteString
def _numToTwoByteString(value, numberOfDecimals=0, LsbFirst=False, signed=False): """Convert a numerical value to a two-byte string, possibly scaling it. Args: * value (float or int): The numerical value to be converted. * numberOfDecimals (int): Number of decimals, 0 or more, for scaling. ...
python
def _numToTwoByteString(value, numberOfDecimals=0, LsbFirst=False, signed=False): """Convert a numerical value to a two-byte string, possibly scaling it. Args: * value (float or int): The numerical value to be converted. * numberOfDecimals (int): Number of decimals, 0 or more, for scaling. ...
[ "def", "_numToTwoByteString", "(", "value", ",", "numberOfDecimals", "=", "0", ",", "LsbFirst", "=", "False", ",", "signed", "=", "False", ")", ":", "_checkNumerical", "(", "value", ",", "description", "=", "'inputvalue'", ")", "_checkInt", "(", "numberOfDecim...
Convert a numerical value to a two-byte string, possibly scaling it. Args: * value (float or int): The numerical value to be converted. * numberOfDecimals (int): Number of decimals, 0 or more, for scaling. * LsbFirst (bol): Whether the least significant byte should be first in the resulting...
[ "Convert", "a", "numerical", "value", "to", "a", "two", "-", "byte", "string", "possibly", "scaling", "it", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1219-L1277
pyhys/minimalmodbus
minimalmodbus.py
_twoByteStringToNum
def _twoByteStringToNum(bytestring, numberOfDecimals=0, signed=False): """Convert a two-byte string to a numerical value, possibly scaling it. Args: * bytestring (str): A string of length 2. * numberOfDecimals (int): The number of decimals. Defaults to 0. * signed (bol): Whether large p...
python
def _twoByteStringToNum(bytestring, numberOfDecimals=0, signed=False): """Convert a two-byte string to a numerical value, possibly scaling it. Args: * bytestring (str): A string of length 2. * numberOfDecimals (int): The number of decimals. Defaults to 0. * signed (bol): Whether large p...
[ "def", "_twoByteStringToNum", "(", "bytestring", ",", "numberOfDecimals", "=", "0", ",", "signed", "=", "False", ")", ":", "_checkString", "(", "bytestring", ",", "minlength", "=", "2", ",", "maxlength", "=", "2", ",", "description", "=", "'bytestring'", ")"...
Convert a two-byte string to a numerical value, possibly scaling it. Args: * bytestring (str): A string of length 2. * numberOfDecimals (int): The number of decimals. Defaults to 0. * signed (bol): Whether large positive values should be interpreted as negative values. Returns: ...
[ "Convert", "a", "two", "-", "byte", "string", "to", "a", "numerical", "value", "possibly", "scaling", "it", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1280-L1323
pyhys/minimalmodbus
minimalmodbus.py
_pack
def _pack(formatstring, value): """Pack a value into a bytestring. Uses the built-in :mod:`struct` Python module. Args: * formatstring (str): String for the packing. See the :mod:`struct` module for details. * value (depends on formatstring): The value to be packed Returns: A ...
python
def _pack(formatstring, value): """Pack a value into a bytestring. Uses the built-in :mod:`struct` Python module. Args: * formatstring (str): String for the packing. See the :mod:`struct` module for details. * value (depends on formatstring): The value to be packed Returns: A ...
[ "def", "_pack", "(", "formatstring", ",", "value", ")", ":", "_checkString", "(", "formatstring", ",", "description", "=", "'formatstring'", ",", "minlength", "=", "1", ")", "try", ":", "result", "=", "struct", ".", "pack", "(", "formatstring", ",", "value...
Pack a value into a bytestring. Uses the built-in :mod:`struct` Python module. Args: * formatstring (str): String for the packing. See the :mod:`struct` module for details. * value (depends on formatstring): The value to be packed Returns: A bytestring (str). Raises: ...
[ "Pack", "a", "value", "into", "a", "bytestring", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1597-L1627
pyhys/minimalmodbus
minimalmodbus.py
_unpack
def _unpack(formatstring, packed): """Unpack a bytestring into a value. Uses the built-in :mod:`struct` Python module. Args: * formatstring (str): String for the packing. See the :mod:`struct` module for details. * packed (str): The bytestring to be unpacked. Returns: A value....
python
def _unpack(formatstring, packed): """Unpack a bytestring into a value. Uses the built-in :mod:`struct` Python module. Args: * formatstring (str): String for the packing. See the :mod:`struct` module for details. * packed (str): The bytestring to be unpacked. Returns: A value....
[ "def", "_unpack", "(", "formatstring", ",", "packed", ")", ":", "_checkString", "(", "formatstring", ",", "description", "=", "'formatstring'", ",", "minlength", "=", "1", ")", "_checkString", "(", "packed", ",", "description", "=", "'packed string'", ",", "mi...
Unpack a bytestring into a value. Uses the built-in :mod:`struct` Python module. Args: * formatstring (str): String for the packing. See the :mod:`struct` module for details. * packed (str): The bytestring to be unpacked. Returns: A value. The type depends on the formatstring. ...
[ "Unpack", "a", "bytestring", "into", "a", "value", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1630-L1662
pyhys/minimalmodbus
minimalmodbus.py
_hexencode
def _hexencode(bytestring, insert_spaces = False): """Convert a byte string to a hex encoded string. For example 'J' will return '4A', and ``'\\x04'`` will return '04'. Args: bytestring (str): Can be for example ``'A\\x01B\\x45'``. insert_spaces (bool): Insert space characters between pair...
python
def _hexencode(bytestring, insert_spaces = False): """Convert a byte string to a hex encoded string. For example 'J' will return '4A', and ``'\\x04'`` will return '04'. Args: bytestring (str): Can be for example ``'A\\x01B\\x45'``. insert_spaces (bool): Insert space characters between pair...
[ "def", "_hexencode", "(", "bytestring", ",", "insert_spaces", "=", "False", ")", ":", "_checkString", "(", "bytestring", ",", "description", "=", "'byte string'", ")", "separator", "=", "''", "if", "not", "insert_spaces", "else", "' '", "# Use plain string formatt...
Convert a byte string to a hex encoded string. For example 'J' will return '4A', and ``'\\x04'`` will return '04'. Args: bytestring (str): Can be for example ``'A\\x01B\\x45'``. insert_spaces (bool): Insert space characters between pair of characters to increase readability. Returns: ...
[ "Convert", "a", "byte", "string", "to", "a", "hex", "encoded", "string", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1665-L1692
pyhys/minimalmodbus
minimalmodbus.py
_hexdecode
def _hexdecode(hexstring): """Convert a hex encoded string to a byte string. For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1). Args: hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length. Allowed characters are '0' to '9', 'a' to ...
python
def _hexdecode(hexstring): """Convert a hex encoded string to a byte string. For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1). Args: hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length. Allowed characters are '0' to '9', 'a' to ...
[ "def", "_hexdecode", "(", "hexstring", ")", ":", "# Note: For Python3 the appropriate would be: raise TypeError(new_error_message) from err", "# but the Python2 interpreter will indicate SyntaxError.", "# Thus we need to live with this warning in Python3:", "# 'During handling of the above excepti...
Convert a hex encoded string to a byte string. For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1). Args: hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length. Allowed characters are '0' to '9', 'a' to 'f' and 'A' to 'F' (not space). ...
[ "Convert", "a", "hex", "encoded", "string", "to", "a", "byte", "string", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1695-L1733
pyhys/minimalmodbus
minimalmodbus.py
_bitResponseToValue
def _bitResponseToValue(bytestring): """Convert a response string to a numerical value. Args: bytestring (str): A string of length 1. Can be for example ``\\x01``. Returns: The converted value (int). Raises: TypeError, ValueError """ _checkString(bytestring, descripti...
python
def _bitResponseToValue(bytestring): """Convert a response string to a numerical value. Args: bytestring (str): A string of length 1. Can be for example ``\\x01``. Returns: The converted value (int). Raises: TypeError, ValueError """ _checkString(bytestring, descripti...
[ "def", "_bitResponseToValue", "(", "bytestring", ")", ":", "_checkString", "(", "bytestring", ",", "description", "=", "'bytestring'", ",", "minlength", "=", "1", ",", "maxlength", "=", "1", ")", "RESPONSE_ON", "=", "'\\x01'", "RESPONSE_OFF", "=", "'\\x00'", "...
Convert a response string to a numerical value. Args: bytestring (str): A string of length 1. Can be for example ``\\x01``. Returns: The converted value (int). Raises: TypeError, ValueError
[ "Convert", "a", "response", "string", "to", "a", "numerical", "value", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1747-L1770
pyhys/minimalmodbus
minimalmodbus.py
_createBitpattern
def _createBitpattern(functioncode, value): """Create the bit pattern that is used for writing single bits. This is basically a storage of numerical constants. Args: * functioncode (int): can be 5 or 15 * value (int): can be 0 or 1 Returns: The bit pattern (string). Raise...
python
def _createBitpattern(functioncode, value): """Create the bit pattern that is used for writing single bits. This is basically a storage of numerical constants. Args: * functioncode (int): can be 5 or 15 * value (int): can be 0 or 1 Returns: The bit pattern (string). Raise...
[ "def", "_createBitpattern", "(", "functioncode", ",", "value", ")", ":", "_checkFunctioncode", "(", "functioncode", ",", "[", "5", ",", "15", "]", ")", "_checkInt", "(", "value", ",", "minvalue", "=", "0", ",", "maxvalue", "=", "1", ",", "description", "...
Create the bit pattern that is used for writing single bits. This is basically a storage of numerical constants. Args: * functioncode (int): can be 5 or 15 * value (int): can be 0 or 1 Returns: The bit pattern (string). Raises: TypeError, ValueError
[ "Create", "the", "bit", "pattern", "that", "is", "used", "for", "writing", "single", "bits", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1773-L1802
pyhys/minimalmodbus
minimalmodbus.py
_twosComplement
def _twosComplement(x, bits=16): """Calculate the two's complement of an integer. Then also negative values can be represented by an upper range of positive values. See https://en.wikipedia.org/wiki/Two%27s_complement Args: * x (int): input integer. * bits (int): number of bits, must b...
python
def _twosComplement(x, bits=16): """Calculate the two's complement of an integer. Then also negative values can be represented by an upper range of positive values. See https://en.wikipedia.org/wiki/Two%27s_complement Args: * x (int): input integer. * bits (int): number of bits, must b...
[ "def", "_twosComplement", "(", "x", ",", "bits", "=", "16", ")", ":", "_checkInt", "(", "bits", ",", "minvalue", "=", "0", ",", "description", "=", "'number of bits'", ")", "_checkInt", "(", "x", ",", "description", "=", "'input'", ")", "upperlimit", "="...
Calculate the two's complement of an integer. Then also negative values can be represented by an upper range of positive values. See https://en.wikipedia.org/wiki/Two%27s_complement Args: * x (int): input integer. * bits (int): number of bits, must be > 0. Returns: An int, tha...
[ "Calculate", "the", "two", "s", "complement", "of", "an", "integer", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1809-L1847
pyhys/minimalmodbus
minimalmodbus.py
_fromTwosComplement
def _fromTwosComplement(x, bits=16): """Calculate the inverse(?) of a two's complement of an integer. Args: * x (int): input integer. * bits (int): number of bits, must be > 0. Returns: An int, that represents the inverse(?) of two's complement of the input. Example for bits=8...
python
def _fromTwosComplement(x, bits=16): """Calculate the inverse(?) of a two's complement of an integer. Args: * x (int): input integer. * bits (int): number of bits, must be > 0. Returns: An int, that represents the inverse(?) of two's complement of the input. Example for bits=8...
[ "def", "_fromTwosComplement", "(", "x", ",", "bits", "=", "16", ")", ":", "_checkInt", "(", "bits", ",", "minvalue", "=", "0", ",", "description", "=", "'number of bits'", ")", "_checkInt", "(", "x", ",", "description", "=", "'input'", ")", "upperlimit", ...
Calculate the inverse(?) of a two's complement of an integer. Args: * x (int): input integer. * bits (int): number of bits, must be > 0. Returns: An int, that represents the inverse(?) of two's complement of the input. Example for bits=8: === ======= x returns === =...
[ "Calculate", "the", "inverse", "(", "?", ")", "of", "a", "two", "s", "complement", "of", "an", "integer", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1850-L1887
pyhys/minimalmodbus
minimalmodbus.py
_setBitOn
def _setBitOn(x, bitNum): """Set bit 'bitNum' to True. Args: * x (int): The value before. * bitNum (int): The bit number that should be set to True. Returns: The value after setting the bit. This is an integer. For example: For x = 4 (dec) = 0100 (bin), setting bit num...
python
def _setBitOn(x, bitNum): """Set bit 'bitNum' to True. Args: * x (int): The value before. * bitNum (int): The bit number that should be set to True. Returns: The value after setting the bit. This is an integer. For example: For x = 4 (dec) = 0100 (bin), setting bit num...
[ "def", "_setBitOn", "(", "x", ",", "bitNum", ")", ":", "_checkInt", "(", "x", ",", "minvalue", "=", "0", ",", "description", "=", "'input value'", ")", "_checkInt", "(", "bitNum", ",", "minvalue", "=", "0", ",", "description", "=", "'bitnumber'", ")", ...
Set bit 'bitNum' to True. Args: * x (int): The value before. * bitNum (int): The bit number that should be set to True. Returns: The value after setting the bit. This is an integer. For example: For x = 4 (dec) = 0100 (bin), setting bit number 0 results in 0101 (bin) = 5 (...
[ "Set", "bit", "bitNum", "to", "True", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1893-L1910
pyhys/minimalmodbus
minimalmodbus.py
_calculateCrcString
def _calculateCrcString(inputstring): """Calculate CRC-16 for Modbus. Args: inputstring (str): An arbitrary-length message (without the CRC). Returns: A two-byte CRC string, where the least significant byte is first. """ _checkString(inputstring, description='input CRC string') ...
python
def _calculateCrcString(inputstring): """Calculate CRC-16 for Modbus. Args: inputstring (str): An arbitrary-length message (without the CRC). Returns: A two-byte CRC string, where the least significant byte is first. """ _checkString(inputstring, description='input CRC string') ...
[ "def", "_calculateCrcString", "(", "inputstring", ")", ":", "_checkString", "(", "inputstring", ",", "description", "=", "'input CRC string'", ")", "# Preload a 16-bit register with ones", "register", "=", "0xFFFF", "for", "char", "in", "inputstring", ":", "register", ...
Calculate CRC-16 for Modbus. Args: inputstring (str): An arbitrary-length message (without the CRC). Returns: A two-byte CRC string, where the least significant byte is first.
[ "Calculate", "CRC", "-", "16", "for", "Modbus", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1965-L1983
pyhys/minimalmodbus
minimalmodbus.py
_calculateLrcString
def _calculateLrcString(inputstring): """Calculate LRC for Modbus. Args: inputstring (str): An arbitrary-length message (without the beginning colon and terminating CRLF). It should already be decoded from hex-string. Returns: A one-byte LRC bytestring (not encoded to hex-string) ...
python
def _calculateLrcString(inputstring): """Calculate LRC for Modbus. Args: inputstring (str): An arbitrary-length message (without the beginning colon and terminating CRLF). It should already be decoded from hex-string. Returns: A one-byte LRC bytestring (not encoded to hex-string) ...
[ "def", "_calculateLrcString", "(", "inputstring", ")", ":", "_checkString", "(", "inputstring", ",", "description", "=", "'input LRC string'", ")", "register", "=", "0", "for", "character", "in", "inputstring", ":", "register", "+=", "ord", "(", "character", ")"...
Calculate LRC for Modbus. Args: inputstring (str): An arbitrary-length message (without the beginning colon and terminating CRLF). It should already be decoded from hex-string. Returns: A one-byte LRC bytestring (not encoded to hex-string) Algorithm from the document 'MODBUS over ...
[ "Calculate", "LRC", "for", "Modbus", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1986-L2016
pyhys/minimalmodbus
minimalmodbus.py
_checkMode
def _checkMode(mode): """Check that the Modbus mode is valie. Args: mode (string): The Modbus mode (MODE_RTU or MODE_ASCII) Raises: TypeError, ValueError """ if not isinstance(mode, str): raise TypeError('The {0} should be a string. Given: {1!r}'.format("mode", mode)) ...
python
def _checkMode(mode): """Check that the Modbus mode is valie. Args: mode (string): The Modbus mode (MODE_RTU or MODE_ASCII) Raises: TypeError, ValueError """ if not isinstance(mode, str): raise TypeError('The {0} should be a string. Given: {1!r}'.format("mode", mode)) ...
[ "def", "_checkMode", "(", "mode", ")", ":", "if", "not", "isinstance", "(", "mode", ",", "str", ")", ":", "raise", "TypeError", "(", "'The {0} should be a string. Given: {1!r}'", ".", "format", "(", "\"mode\"", ",", "mode", ")", ")", "if", "mode", "not", "...
Check that the Modbus mode is valie. Args: mode (string): The Modbus mode (MODE_RTU or MODE_ASCII) Raises: TypeError, ValueError
[ "Check", "that", "the", "Modbus", "mode", "is", "valie", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2019-L2034
pyhys/minimalmodbus
minimalmodbus.py
_checkFunctioncode
def _checkFunctioncode(functioncode, listOfAllowedValues=[]): """Check that the given functioncode is in the listOfAllowedValues. Also verifies that 1 <= function code <= 127. Args: * functioncode (int): The function code * listOfAllowedValues (list of int): Allowed values. Use *None* to b...
python
def _checkFunctioncode(functioncode, listOfAllowedValues=[]): """Check that the given functioncode is in the listOfAllowedValues. Also verifies that 1 <= function code <= 127. Args: * functioncode (int): The function code * listOfAllowedValues (list of int): Allowed values. Use *None* to b...
[ "def", "_checkFunctioncode", "(", "functioncode", ",", "listOfAllowedValues", "=", "[", "]", ")", ":", "FUNCTIONCODE_MIN", "=", "1", "FUNCTIONCODE_MAX", "=", "127", "_checkInt", "(", "functioncode", ",", "FUNCTIONCODE_MIN", ",", "FUNCTIONCODE_MAX", ",", "description...
Check that the given functioncode is in the listOfAllowedValues. Also verifies that 1 <= function code <= 127. Args: * functioncode (int): The function code * listOfAllowedValues (list of int): Allowed values. Use *None* to bypass this part of the checking. Raises: TypeError, Valu...
[ "Check", "that", "the", "given", "functioncode", "is", "in", "the", "listOfAllowedValues", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2037-L2065
pyhys/minimalmodbus
minimalmodbus.py
_checkResponseByteCount
def _checkResponseByteCount(payload): """Check that the number of bytes as given in the response is correct. The first byte in the payload indicates the length of the payload (first byte not counted). Args: payload (string): The payload Raises: TypeError, ValueError """ POSIT...
python
def _checkResponseByteCount(payload): """Check that the number of bytes as given in the response is correct. The first byte in the payload indicates the length of the payload (first byte not counted). Args: payload (string): The payload Raises: TypeError, ValueError """ POSIT...
[ "def", "_checkResponseByteCount", "(", "payload", ")", ":", "POSITION_FOR_GIVEN_NUMBER", "=", "0", "NUMBER_OF_BYTES_TO_SKIP", "=", "1", "_checkString", "(", "payload", ",", "minlength", "=", "1", ",", "description", "=", "'payload'", ")", "givenNumberOfDatabytes", "...
Check that the number of bytes as given in the response is correct. The first byte in the payload indicates the length of the payload (first byte not counted). Args: payload (string): The payload Raises: TypeError, ValueError
[ "Check", "that", "the", "number", "of", "bytes", "as", "given", "in", "the", "response", "is", "correct", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2100-L2124
pyhys/minimalmodbus
minimalmodbus.py
_checkResponseRegisterAddress
def _checkResponseRegisterAddress(payload, registeraddress): """Check that the start adress as given in the response is correct. The first two bytes in the payload holds the address value. Args: * payload (string): The payload * registeraddress (int): The register address (use decimal numb...
python
def _checkResponseRegisterAddress(payload, registeraddress): """Check that the start adress as given in the response is correct. The first two bytes in the payload holds the address value. Args: * payload (string): The payload * registeraddress (int): The register address (use decimal numb...
[ "def", "_checkResponseRegisterAddress", "(", "payload", ",", "registeraddress", ")", ":", "_checkString", "(", "payload", ",", "minlength", "=", "2", ",", "description", "=", "'payload'", ")", "_checkRegisteraddress", "(", "registeraddress", ")", "BYTERANGE_FOR_STARTA...
Check that the start adress as given in the response is correct. The first two bytes in the payload holds the address value. Args: * payload (string): The payload * registeraddress (int): The register address (use decimal numbers, not hex). Raises: TypeError, ValueError
[ "Check", "that", "the", "start", "adress", "as", "given", "in", "the", "response", "is", "correct", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2127-L2150
pyhys/minimalmodbus
minimalmodbus.py
_checkResponseNumberOfRegisters
def _checkResponseNumberOfRegisters(payload, numberOfRegisters): """Check that the number of written registers as given in the response is correct. The bytes 2 and 3 (zero based counting) in the payload holds the value. Args: * payload (string): The payload * numberOfRegisters (int): Numbe...
python
def _checkResponseNumberOfRegisters(payload, numberOfRegisters): """Check that the number of written registers as given in the response is correct. The bytes 2 and 3 (zero based counting) in the payload holds the value. Args: * payload (string): The payload * numberOfRegisters (int): Numbe...
[ "def", "_checkResponseNumberOfRegisters", "(", "payload", ",", "numberOfRegisters", ")", ":", "_checkString", "(", "payload", ",", "minlength", "=", "4", ",", "description", "=", "'payload'", ")", "_checkInt", "(", "numberOfRegisters", ",", "minvalue", "=", "1", ...
Check that the number of written registers as given in the response is correct. The bytes 2 and 3 (zero based counting) in the payload holds the value. Args: * payload (string): The payload * numberOfRegisters (int): Number of registers that have been written Raises: TypeError, Va...
[ "Check", "that", "the", "number", "of", "written", "registers", "as", "given", "in", "the", "response", "is", "correct", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2153-L2176
pyhys/minimalmodbus
minimalmodbus.py
_checkResponseWriteData
def _checkResponseWriteData(payload, writedata): """Check that the write data as given in the response is correct. The bytes 2 and 3 (zero based counting) in the payload holds the write data. Args: * payload (string): The payload * writedata (string): The data to write, length should be 2 ...
python
def _checkResponseWriteData(payload, writedata): """Check that the write data as given in the response is correct. The bytes 2 and 3 (zero based counting) in the payload holds the write data. Args: * payload (string): The payload * writedata (string): The data to write, length should be 2 ...
[ "def", "_checkResponseWriteData", "(", "payload", ",", "writedata", ")", ":", "_checkString", "(", "payload", ",", "minlength", "=", "4", ",", "description", "=", "'payload'", ")", "_checkString", "(", "writedata", ",", "minlength", "=", "2", ",", "maxlength",...
Check that the write data as given in the response is correct. The bytes 2 and 3 (zero based counting) in the payload holds the write data. Args: * payload (string): The payload * writedata (string): The data to write, length should be 2 bytes. Raises: TypeError, ValueError
[ "Check", "that", "the", "write", "data", "as", "given", "in", "the", "response", "is", "correct", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2179-L2201
pyhys/minimalmodbus
minimalmodbus.py
_checkString
def _checkString(inputstring, description, minlength=0, maxlength=None): """Check that the given string is valid. Args: * inputstring (string): The string to be checked * description (string): Used in error messages for the checked inputstring * minlength (int): Minimum length of the st...
python
def _checkString(inputstring, description, minlength=0, maxlength=None): """Check that the given string is valid. Args: * inputstring (string): The string to be checked * description (string): Used in error messages for the checked inputstring * minlength (int): Minimum length of the st...
[ "def", "_checkString", "(", "inputstring", ",", "description", ",", "minlength", "=", "0", ",", "maxlength", "=", "None", ")", ":", "# Type checking", "if", "not", "isinstance", "(", "description", ",", "str", ")", ":", "raise", "TypeError", "(", "'The descr...
Check that the given string is valid. Args: * inputstring (string): The string to be checked * description (string): Used in error messages for the checked inputstring * minlength (int): Minimum length of the string * maxlength (int or None): Maximum length of the string Raises...
[ "Check", "that", "the", "given", "string", "is", "valid", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2204-L2246
pyhys/minimalmodbus
minimalmodbus.py
_checkInt
def _checkInt(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'): """Check that the given integer is valid. Args: * inputvalue (int or long): The integer to be checked * minvalue (int or long, or None): Minimum value of the integer * maxvalue (int or long, or None): Max...
python
def _checkInt(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'): """Check that the given integer is valid. Args: * inputvalue (int or long): The integer to be checked * minvalue (int or long, or None): Minimum value of the integer * maxvalue (int or long, or None): Max...
[ "def", "_checkInt", "(", "inputvalue", ",", "minvalue", "=", "None", ",", "maxvalue", "=", "None", ",", "description", "=", "'inputvalue'", ")", ":", "if", "not", "isinstance", "(", "description", ",", "str", ")", ":", "raise", "TypeError", "(", "'The desc...
Check that the given integer is valid. Args: * inputvalue (int or long): The integer to be checked * minvalue (int or long, or None): Minimum value of the integer * maxvalue (int or long, or None): Maximum value of the integer * description (string): Used in error messages for the c...
[ "Check", "that", "the", "given", "integer", "is", "valid", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2249-L2276
pyhys/minimalmodbus
minimalmodbus.py
_checkNumerical
def _checkNumerical(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'): """Check that the given numerical value is valid. Args: * inputvalue (numerical): The value to be checked. * minvalue (numerical): Minimum value Use None to skip this part of the test. * maxvalue (...
python
def _checkNumerical(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'): """Check that the given numerical value is valid. Args: * inputvalue (numerical): The value to be checked. * minvalue (numerical): Minimum value Use None to skip this part of the test. * maxvalue (...
[ "def", "_checkNumerical", "(", "inputvalue", ",", "minvalue", "=", "None", ",", "maxvalue", "=", "None", ",", "description", "=", "'inputvalue'", ")", ":", "# Type checking", "if", "not", "isinstance", "(", "description", ",", "str", ")", ":", "raise", "Type...
Check that the given numerical value is valid. Args: * inputvalue (numerical): The value to be checked. * minvalue (numerical): Minimum value Use None to skip this part of the test. * maxvalue (numerical): Maximum value. Use None to skip this part of the test. * description (string...
[ "Check", "that", "the", "given", "numerical", "value", "is", "valid", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2279-L2322
pyhys/minimalmodbus
minimalmodbus.py
_checkBool
def _checkBool(inputvalue, description='inputvalue'): """Check that the given inputvalue is a boolean. Args: * inputvalue (boolean): The value to be checked. * description (string): Used in error messages for the checked inputvalue. Raises: TypeError, ValueError """ _check...
python
def _checkBool(inputvalue, description='inputvalue'): """Check that the given inputvalue is a boolean. Args: * inputvalue (boolean): The value to be checked. * description (string): Used in error messages for the checked inputvalue. Raises: TypeError, ValueError """ _check...
[ "def", "_checkBool", "(", "inputvalue", ",", "description", "=", "'inputvalue'", ")", ":", "_checkString", "(", "description", ",", "minlength", "=", "1", ",", "description", "=", "'description string'", ")", "if", "not", "isinstance", "(", "inputvalue", ",", ...
Check that the given inputvalue is a boolean. Args: * inputvalue (boolean): The value to be checked. * description (string): Used in error messages for the checked inputvalue. Raises: TypeError, ValueError
[ "Check", "that", "the", "given", "inputvalue", "is", "a", "boolean", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2325-L2338
pyhys/minimalmodbus
minimalmodbus.py
_interpretRawMessage
def _interpretRawMessage(inputstr): r"""Generate a human readable description of a Modbus bytestring. Args: inputstr (str): The bytestring that should be interpreted. Returns: A descriptive string. For example, the string ``'\n\x03\x10\x01\x00\x01\xd0q'`` should give something lik...
python
def _interpretRawMessage(inputstr): r"""Generate a human readable description of a Modbus bytestring. Args: inputstr (str): The bytestring that should be interpreted. Returns: A descriptive string. For example, the string ``'\n\x03\x10\x01\x00\x01\xd0q'`` should give something lik...
[ "def", "_interpretRawMessage", "(", "inputstr", ")", ":", "raise", "NotImplementedError", "(", ")", "output", "=", "''", "output", "+=", "'Modbus bytestring decoder\\n'", "output", "+=", "'Input string (length {} characters): {!r} \\n'", ".", "format", "(", "len", "(", ...
r"""Generate a human readable description of a Modbus bytestring. Args: inputstr (str): The bytestring that should be interpreted. Returns: A descriptive string. For example, the string ``'\n\x03\x10\x01\x00\x01\xd0q'`` should give something like:: TODO: update ...
[ "r", "Generate", "a", "human", "readable", "description", "of", "a", "Modbus", "bytestring", ".", "Args", ":", "inputstr", "(", "str", ")", ":", "The", "bytestring", "that", "should", "be", "interpreted", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2360-L2481
pyhys/minimalmodbus
minimalmodbus.py
_interpretPayload
def _interpretPayload(functioncode, payload): r"""Generate a human readable description of a Modbus payload. Args: * functioncode (int): Function code * payload (str): The payload that should be interpreted. It should be a byte string. Returns: A descriptive string. For exampl...
python
def _interpretPayload(functioncode, payload): r"""Generate a human readable description of a Modbus payload. Args: * functioncode (int): Function code * payload (str): The payload that should be interpreted. It should be a byte string. Returns: A descriptive string. For exampl...
[ "def", "_interpretPayload", "(", "functioncode", ",", "payload", ")", ":", "raise", "NotImplementedError", "(", ")", "output", "=", "''", "output", "+=", "'Modbus payload decoder\\n'", "output", "+=", "'Input payload (length {} characters): {!r} \\n'", ".", "format", "(...
r"""Generate a human readable description of a Modbus payload. Args: * functioncode (int): Function code * payload (str): The payload that should be interpreted. It should be a byte string. Returns: A descriptive string. For example, the payload ``'\x10\x01\x00\x01'`` for function...
[ "r", "Generate", "a", "human", "readable", "description", "of", "a", "Modbus", "payload", ".", "Args", ":", "*", "functioncode", "(", "int", ")", ":", "Function", "code", "*", "payload", "(", "str", ")", ":", "The", "payload", "that", "should", "be", "...
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2484-L2511
pyhys/minimalmodbus
minimalmodbus.py
_getDiagnosticString
def _getDiagnosticString(): """Generate a diagnostic string, showing the module version, the platform, current directory etc. Returns: A descriptive string. """ text = '\n## Diagnostic output from minimalmodbus ## \n\n' text += 'Minimalmodbus version: ' + __version__ + '\n' text += 'Mi...
python
def _getDiagnosticString(): """Generate a diagnostic string, showing the module version, the platform, current directory etc. Returns: A descriptive string. """ text = '\n## Diagnostic output from minimalmodbus ## \n\n' text += 'Minimalmodbus version: ' + __version__ + '\n' text += 'Mi...
[ "def", "_getDiagnosticString", "(", ")", ":", "text", "=", "'\\n## Diagnostic output from minimalmodbus ## \\n\\n'", "text", "+=", "'Minimalmodbus version: '", "+", "__version__", "+", "'\\n'", "text", "+=", "'Minimalmodbus status: '", "+", "__status__", "+", "'\\n'", "te...
Generate a diagnostic string, showing the module version, the platform, current directory etc. Returns: A descriptive string.
[ "Generate", "a", "diagnostic", "string", "showing", "the", "module", "version", "the", "platform", "current", "directory", "etc", "." ]
train
https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2513-L2550