DebugSession

class DebugSession(host=None, port=None)

DebugSession class for controlling session

Parameters:
  • host (str, optional) – hostname of DebugSession to connect to (default=”localhost”)
  • port (int) – port number of DebugSession to connect to

Warning

You should never instantiate this class directly. Instead call the DebugServer.open_session() function to create a DebugSession object

connect()

Connect to the device.

disconnect()

Disconnect from the device.

erase()

Erases device’s flash memory.

evaluate(expression, file=None)

Evaluates an expression (after loading optional symbols file)

Parameters:
  • expression (str) – C/GEL expression to evaluate
  • file (str, optional) – path to file containing symbols to load before evaluating
Returns:

result of evaluated expression

Return type:

int

Raises:

Exception if expression is invalid.

get_option(option_id)

Get the value of a device option

Parameters:option_id (str) – name of device option
Returns:value of option
Return type:any
Raises:Exception if option id is invalid.
halt(wait=False)

Halts the device

Parameters:wait (boolean) – wait until device is actually halted before returning
load(file, binary=False, address=None)

Loads image into device’s flash.

Parameters:
  • file (str) – full path to file to load into flash
  • binary (boolean, optional) – specify to load image as binary (default = False)
  • address (int, optional) – specify to load binary image at specifc address (only to be used when ‘binary’ is True; default=0x0)
Raises:

Exception if image fails to load

perform_operation(opcode)

Performs flash operation

Parameters:opcode (str) – name of operation to perform (opcode)
Returns:returns value of performing operation
Return type:any
Raises:Exception if opcode is invalid.
read_data(address, page=0, num_bytes=1)

Read memory from device

Parameters:
  • address (int) – address to read data from
  • page (int, optional) – page in memory to get address from (default = 0)
  • num_bytes (int, optional) – number of bytes to read
Returns:

list of bytes(ints) read

Return type:

list

Raises:

Exception if address location is invalid.

read_register(name)

Read value from register

Parameters:name (str) – register name to read
Returns:value of register read
Return type:int
Raises:Exception if register name is invalid.
reset()

Resets device.

run(asynchronous=False)

Issues the run command to the device

Parameters:asynchronous (boolean, optional) – run and return control immediately (default = False)
set_option(option_id, value)

Set the value of a device option

Parameters:
  • option_id (str) – name of device option
  • value (any) – value to set option to
Raises:

Exception if option id is invalid.

stop()

Stops the session thread but does not terminate the session.

verify(file, binary=False, address=None)

Verifies image in device’s flash.

Parameters:
  • file (str) – full path to file to verify in flash
  • binary (boolean, optional) – specify to verify image as binary (default = False)
  • address (int, optional) – specify to verify binary image at specifc address (only to be used when ‘binary’ is True; default=0x0)
Raises:

Exception if image fails verification process

write_data(data, address, page=0)

Write to memory on device

Parameters:
  • data (list) – list of bytes (ints) to write to memory
  • address (int) – address to read data from
  • page (int, optional) – page in memory to get address from (default = 0)
Raises:

Exception if address location is invalid.

write_register(name, value)

Write value to register on device

Parameters:
  • name (str) – register name to write to
  • value (int) – value to write to register
Raises:

Exception if register name is invalid.