spinnman.utilities.io package

Submodules

spinnman.utilities.io.abstract_io module

class spinnman.utilities.io.abstract_io.AbstractIO[source]

Bases: object

address

Return the current absolute address within the region

close()[source]

Close the IO object

closed

Indicates if the object has been closed

fill(repeat_value, bytes_to_fill=None, data_type=<FillDataType.WORD: 4>)[source]

Fill the next part of the region with repeated data

Parameters:
  • repeat_value (int) – The value to repeat
  • bytes_to_fill (int) – Optional number of bytes to fill from current position, or None to fill to the end
  • data_type (spinnman.process.fill_process.FillDataType) – The type of the repeat value
Raises:

EOFError – If the amount of data to fill is more than the region

flush()[source]

Flush any outstanding written data

read(n_bytes=None)[source]

Read a number of bytes, or the rest of the data if n_bytes is None or negative

Parameters:n_bytes – The number of bytes to read
Return type:bytes
Raises:EOFError – If the read will be beyond the end of the region
seek(n_bytes, from_what=0)[source]

Seek to a position within the region

tell()[source]

Return the current position within the region relative to the start

write(data)[source]

Write some data to the region

Parameters:data (bytes) – The data to write
Returns:The number of bytes written
Return type:int
Raises:EOFError – If the write will go over the end of the region

spinnman.utilities.io.file_io module

class spinnman.utilities.io.file_io.FileIO(file_obj, start_offset, end_offset)[source]

Bases: spinnman.utilities.io.abstract_io.AbstractIO

A file input/output interface to match the MemoryIO interface

Parameters:
  • file_obj (str or file) – The file handle or file name to write to
  • start_offset (int) – The start offset into the file
  • end_offset (int or None) – The end offset from the start of the file
address

Return the current absolute address within the region

close()[source]

Close the IO object

closed

Indicates if the object has been closed

fill(repeat_value, bytes_to_fill=None, data_type=<FillDataType.WORD: 4>)[source]

Fill the next part of the region with repeated data

Parameters:
  • repeat_value (int) – The value to repeat
  • bytes_to_fill (int) – Optional number of bytes to fill from current position, or None to fill to the end
  • data_type (spinnman.process.fill_process.FillDataType) – The type of the repeat value
Raises:

EOFError – If the amount of data to fill is more than the region

flush()[source]

Flush any outstanding written data

read(n_bytes=None)[source]

Read a number of bytes, or the rest of the data if n_bytes is None or negative

Parameters:n_bytes – The number of bytes to read
Return type:bytes
Raises:EOFError – If the read will be beyond the end of the region
seek(n_bytes, from_what=0)[source]

Seek to a position within the region

tell()[source]

Return the current position within the region relative to the start

write(data)[source]

Write some data to the region

Parameters:data (bytes) – The data to write
Returns:The number of bytes written
Return type:int
Raises:EOFError – If the write will go over the end of the region

spinnman.utilities.io.memory_io module

class spinnman.utilities.io.memory_io.MemoryIO(transceiver, x, y, start_address, end_address)[source]

Bases: spinnman.utilities.io.abstract_io.AbstractIO

A file-like object for reading and writing memory

Parameters:
  • transceiver – The transceiver to read and write with
  • x – The x-coordinate of the chip to write to
  • y – The y-coordinate of the chip to write to
  • start_address – The start address of the region to write to
  • end_address – The end address of the region to write to. This is the first address just outside the region
address

Return the current absolute address within the region

close()[source]

Close the IO object

closed

Indicates if the object has been closed

fill(repeat_value, bytes_to_fill=None, data_type=<FillDataType.WORD: 4>)[source]

Fill the next part of the region with repeated data

Parameters:
  • repeat_value (int) – The value to repeat
  • bytes_to_fill (int) – Optional number of bytes to fill from current position, or None to fill to the end
  • data_type (spinnman.process.fill_process.FillDataType) – The type of the repeat value
Raises:

EOFError – If the amount of data to fill is more than the region

flush()[source]

Flush any outstanding written data

read(n_bytes=None)[source]

Read a number of bytes, or the rest of the data if n_bytes is None or negative

Parameters:n_bytes – The number of bytes to read
Return type:bytes
Raises:EOFError – If the read will be beyond the end of the region
seek(n_bytes, from_what=0)[source]

Seek to a position within the region Seek to a position within the region

tell()[source]

Return the current position within the region relative to the start

write(data)[source]

Write some data to the region

Parameters:data (bytes) – The data to write
Returns:The number of bytes written
Return type:int
Raises:EOFError – If the write will go over the end of the region

Module contents

class spinnman.utilities.io.AbstractIO[source]

Bases: object

address

Return the current absolute address within the region

close()[source]

Close the IO object

closed

Indicates if the object has been closed

fill(repeat_value, bytes_to_fill=None, data_type=<FillDataType.WORD: 4>)[source]

Fill the next part of the region with repeated data

Parameters:
  • repeat_value (int) – The value to repeat
  • bytes_to_fill (int) – Optional number of bytes to fill from current position, or None to fill to the end
  • data_type (spinnman.process.fill_process.FillDataType) – The type of the repeat value
Raises:

EOFError – If the amount of data to fill is more than the region

flush()[source]

Flush any outstanding written data

read(n_bytes=None)[source]

Read a number of bytes, or the rest of the data if n_bytes is None or negative

Parameters:n_bytes – The number of bytes to read
Return type:bytes
Raises:EOFError – If the read will be beyond the end of the region
seek(n_bytes, from_what=0)[source]

Seek to a position within the region

tell()[source]

Return the current position within the region relative to the start

write(data)[source]

Write some data to the region

Parameters:data (bytes) – The data to write
Returns:The number of bytes written
Return type:int
Raises:EOFError – If the write will go over the end of the region
class spinnman.utilities.io.FileIO(file_obj, start_offset, end_offset)[source]

Bases: spinnman.utilities.io.abstract_io.AbstractIO

A file input/output interface to match the MemoryIO interface

Parameters:
  • file_obj (str or file) – The file handle or file name to write to
  • start_offset (int) – The start offset into the file
  • end_offset (int or None) – The end offset from the start of the file
address

Return the current absolute address within the region

close()[source]

Close the IO object

closed

Indicates if the object has been closed

fill(repeat_value, bytes_to_fill=None, data_type=<FillDataType.WORD: 4>)[source]

Fill the next part of the region with repeated data

Parameters:
  • repeat_value (int) – The value to repeat
  • bytes_to_fill (int) – Optional number of bytes to fill from current position, or None to fill to the end
  • data_type (spinnman.process.fill_process.FillDataType) – The type of the repeat value
Raises:

EOFError – If the amount of data to fill is more than the region

flush()[source]

Flush any outstanding written data

read(n_bytes=None)[source]

Read a number of bytes, or the rest of the data if n_bytes is None or negative

Parameters:n_bytes – The number of bytes to read
Return type:bytes
Raises:EOFError – If the read will be beyond the end of the region
seek(n_bytes, from_what=0)[source]

Seek to a position within the region

tell()[source]

Return the current position within the region relative to the start

write(data)[source]

Write some data to the region

Parameters:data (bytes) – The data to write
Returns:The number of bytes written
Return type:int
Raises:EOFError – If the write will go over the end of the region
class spinnman.utilities.io.MemoryIO(transceiver, x, y, start_address, end_address)[source]

Bases: spinnman.utilities.io.abstract_io.AbstractIO

A file-like object for reading and writing memory

Parameters:
  • transceiver – The transceiver to read and write with
  • x – The x-coordinate of the chip to write to
  • y – The y-coordinate of the chip to write to
  • start_address – The start address of the region to write to
  • end_address – The end address of the region to write to. This is the first address just outside the region
address

Return the current absolute address within the region

close()[source]

Close the IO object

closed

Indicates if the object has been closed

fill(repeat_value, bytes_to_fill=None, data_type=<FillDataType.WORD: 4>)[source]

Fill the next part of the region with repeated data

Parameters:
  • repeat_value (int) – The value to repeat
  • bytes_to_fill (int) – Optional number of bytes to fill from current position, or None to fill to the end
  • data_type (spinnman.process.fill_process.FillDataType) – The type of the repeat value
Raises:

EOFError – If the amount of data to fill is more than the region

flush()[source]

Flush any outstanding written data

read(n_bytes=None)[source]

Read a number of bytes, or the rest of the data if n_bytes is None or negative

Parameters:n_bytes – The number of bytes to read
Return type:bytes
Raises:EOFError – If the read will be beyond the end of the region
seek(n_bytes, from_what=0)[source]

Seek to a position within the region Seek to a position within the region

tell()[source]

Return the current position within the region relative to the start

write(data)[source]

Write some data to the region

Parameters:data (bytes) – The data to write
Returns:The number of bytes written
Return type:int
Raises:EOFError – If the write will go over the end of the region