Skip to content

Not installed with the midas Python package

The mscb module is in $MIDASSYS/mscb/python/mscb.py, not in the midas package. It isn't installed when you set up the midas Python package. To use it, add $MIDASSYS/mscb/python to your PYTHONPATH.

See Slow control: MSCB for an introduction and an example. This page contains the full API reference of the mscb module.

The mscb_* functions work like the C functions of the same names, which are described in the C interface.

The mscb module is pure Python, and talks to Ethernet submasters over UDP. It doesn't need midas or a compiled library.

It has two interfaces:

  • the MSCB class, which opens a submaster in a with statement, and reads and writes the raw bytes of variables. Errors are raised as exceptions
  • the mscb_* functions, with the same arguments as the C library. They return a status code (MSCB_SUCCESS if they worked), and take ctypes objects for the values they fill, such as MSCB_INFO and MSCB_INFO_VAR

There are examples in $MIDASSYS/mscb/examples, and in $MIDASSYS/python/examples/pysequencer_mscb_read.py.

mscb

Pure-Python MSCB client using the Ethernet submaster UDP protocol.

The module intentionally exposes the traditional mscb_* functions so existing Python callers can keep their command and status handling. RPC and USB transports are not present.

mscb.ADDR_SET_GROUP = 3 module-attribute

mscb.ADDR_SET_HIGH = 2 module-attribute

mscb.ADDR_SET_NODE = 1 module-attribute

mscb.EMSCB_COMM_ERROR = -9 module-attribute

mscb.EMSCB_INVAL_PARAM = -7 module-attribute

mscb.EMSCB_LOCKED = -5 module-attribute

mscb.EMSCB_NOT_FOUND = -10 module-attribute

mscb.EMSCB_NO_ACCESS = -4 module-attribute

mscb.EMSCB_NO_MEM = -2 module-attribute

mscb.EMSCB_NO_SUBM = -6 module-attribute

mscb.EMSCB_NO_WRITE_ACCESS = -11 module-attribute

mscb.EMSCB_PROTOCOL_VERSION = -12 module-attribute

mscb.EMSCB_UNDEFINED = -1 module-attribute

mscb.EMSCB_WRONG_PASSWORD = -8 module-attribute

mscb.MCMD_ACK = 120 module-attribute

mscb.MCMD_ADDR_BC = 16 module-attribute

mscb.MCMD_ADDR_GRP16 = 18 module-attribute

mscb.MCMD_ADDR_GRP8 = 17 module-attribute

mscb.MCMD_ADDR_NODE16 = 10 module-attribute

mscb.MCMD_ADDR_NODE8 = 9 module-attribute

mscb.MCMD_ECHO = 97 module-attribute

mscb.MCMD_FLASH = 152 module-attribute

mscb.MCMD_FREEZE = 65 module-attribute

mscb.MCMD_GET_INFO = 40 module-attribute

mscb.MCMD_GET_UPTIME = 112 module-attribute

mscb.MCMD_INIT = 32 module-attribute

mscb.MCMD_LOG = 193 module-attribute

mscb.MCMD_PING16 = 26 module-attribute

mscb.MCMD_PING8 = 25 module-attribute

mscb.MCMD_READ = 160 module-attribute

mscb.MCMD_READ_MEM = 191 module-attribute

mscb.MCMD_SET_ADDR = 51 module-attribute

mscb.MCMD_SET_BAUD = 57 module-attribute

mscb.MCMD_SET_NAME = 55 module-attribute

mscb.MCMD_SET_TIME = 78 module-attribute

mscb.MCMD_TOKEN = 104 module-attribute

mscb.MCMD_UPGRADE = 80 module-attribute

mscb.MCMD_USER = 88 module-attribute

mscb.MCMD_WRITE_ACK = 136 module-attribute

mscb.MCMD_WRITE_MEM = 183 module-attribute

mscb.MCMD_WRITE_NA = 128 module-attribute

mscb.MCMD_WRITE_RANGE = 168 module-attribute

mscb.MSCB_ADDR_EXISTS = 10 module-attribute

mscb.MSCB_BASE_CODE = 805306368 module-attribute

mscb.MSCB_BASE_FLASH = 536870912 module-attribute

mscb.MSCB_BASE_NVRAM = 268435456 module-attribute

mscb.MSCB_BASE_RAM = 0 module-attribute

mscb.MSCB_CRC_ERROR = 2 module-attribute

mscb.MSCB_FORMAT_ERROR = 7 module-attribute

mscb.MSCB_INVALID_INDEX = 15 module-attribute

mscb.MSCB_INVAL_PARAM = 5 module-attribute

mscb.MSCB_LIBRARY_VERSION = '2.7.0-py' module-attribute

mscb.MSCB_MAX_FD = 1024 module-attribute

mscb.MSCB_MUTEX = 6 module-attribute

mscb.MSCB_NET_PORT = 1177 module-attribute

mscb.MSCB_NOTREADY = 13 module-attribute

mscb.MSCB_NOT_FOUND = 16 module-attribute

mscb.MSCB_NO_MEM = 8 module-attribute

mscb.MSCB_NO_VAR = 14 module-attribute

mscb.MSCB_PROTOCOL_VERSION = 5 module-attribute

mscb.MSCB_SUBADDR = 12 module-attribute

mscb.MSCB_SUBM_ERROR = 9 module-attribute

mscb.MSCB_SUCCESS = 1 module-attribute

mscb.MSCB_TIMEOUT = 3 module-attribute

mscb.MSCB_TIMEOUT_BUS = 4 module-attribute

mscb.MSCB_UPLOAD_DEBUG = 1 module-attribute

mscb.MSCB_UPLOAD_SUBADDR = 2 module-attribute

mscb.MSCB_WRONG_PASS = 11 module-attribute

mscb.RS485_FLAG_ADR_CYCLE = 1 << 5 module-attribute

mscb.RS485_FLAG_BIT9 = 1 << 0 module-attribute

mscb.RS485_FLAG_CMD = 1 << 4 module-attribute

mscb.RS485_FLAG_LONG_TO = 1 << 3 module-attribute

mscb.RS485_FLAG_NO_ACK = 1 << 1 module-attribute

mscb.RS485_FLAG_NO_RETRY = 1 << 6 module-attribute

mscb.RS485_FLAG_SHORT_TO = 1 << 2 module-attribute

mscb.RS485_FLAG_VERYLONG_TO = 1 << 7 module-attribute

mscb.UCMD_ECHO = 1 module-attribute

mscb.UCMD_ERASE = 2 module-attribute

mscb.UCMD_PROGRAM = 3 module-attribute

mscb.UCMD_READ = 5 module-attribute

mscb.UCMD_REBOOT = 6 module-attribute

mscb.UCMD_RETURN = 7 module-attribute

mscb.UCMD_VERIFY = 4 module-attribute

mscb.XIL_BITFILE_HEADER_ID = 3213798889 module-attribute

mscb.XIL_FW_ADDR = 0 module-attribute

mscb.XIL_FW_HEADER_ADDR = XIL_SW_ADDR - 4096 module-attribute

mscb.XIL_SW_ADDR = 4325376 module-attribute

mscb.XIL_SW_HEADER_ADDR = XIL_SW_ADDR + 2093056 module-attribute

mscb.MSCB

Small Pythonic context-manager facade over the compatible functions.

fd = -1 instance-attribute

__init__(device, password='', debug=0)

close()

connect()

ping(address, retry=False)

read(address, index, size=256)

write(address, index, data)

mscb.MSCB_INFO

Bases: Structure

mscb.MSCB_INFO_VAR

Bases: Structure

mscb.crc8(data, length=None)

Return the Dallas/Maxim CRC-8 used by MSCB.

mscb.host2ip(hostname, ip, size)

mscb.mscb_addr(fd, command, adr, quick, retry)

mscb.mscb_clear_info_cache()

mscb.mscb_clear_log(fd, adr)

mscb.mscb_debug(flag)

mscb.mscb_download(fd, node_adr, sub_adr, filename)

mscb.mscb_echo(fd, adr, d1, d2)

mscb.mscb_exchg(fd, buffer, size, length, flags)

C-compatible low-level exchange entry point.

mscb.mscb_exit(fd)

mscb.mscb_flash(fd, addr, gaddr, broadcast)

mscb.mscb_get_device(fd, device, bufsize)

mscb.mscb_get_eth_max_retry(fd)

mscb.mscb_get_eth_pause(fd)

mscb.mscb_get_max_retry()

mscb.mscb_get_version(lib_version, lib_size, protocol_version, protocol_size)

mscb.mscb_info(fd, adr, info)

mscb.mscb_info_variable(fd, adr, index, info)

mscb.mscb_init(device, device_size=0, password=b'', debug=0)

Open and authenticate an Ethernet MSCB submaster.

mscb.mscb_legacy_verify(fd, adr, buffer)

Synchronize a caller-owned value with a node at most twice per second.

mscb.mscb_ping(fd, adr, quick=0, retry=0)

mscb.mscb_read(fd, adr, index, data, size)

mscb.mscb_read_log(fd, adr, data_buffer, bufsize)

mscb.mscb_read_mem(fd, node_adr, sub_adr, mem_adr, buffer, size)

mscb.mscb_read_no_retries(fd, adr, index, data, size)

mscb.mscb_read_range(fd, adr, index1, index2, data, size)

mscb.mscb_reboot(fd, addr, gaddr, broadcast)

mscb.mscb_scan_udp()

Find Ethernet submasters named MSCB000 through MSCB999.

This intentionally follows the C implementation: resolve each conventional hostname and send a direct submaster ECHO request to every name that exists. A subnet broadcast is not used because it is commonly blocked or ignored.

mscb.mscb_set_baud(fd, baud)

mscb.mscb_set_eth_max_retry(fd, max_retry)

mscb.mscb_set_eth_pause(fd, pause)

mscb.mscb_set_group_addr(fd, addr, gaddr, broadcast, new_addr)

mscb.mscb_set_max_retry(max_retry)

mscb.mscb_set_name(fd, adr, name)

mscb.mscb_set_node_addr(fd, addr, gaddr, broadcast, new_addr)

mscb.mscb_set_time(fd, addr, gaddr, broadcast)

mscb.mscb_subm_info(fd)

mscb.mscb_subm_reset(fd)

mscb.mscb_upload(fd, node_adr, sub_adr, filename, flags)

mscb.mscb_uptime(fd, adr, uptime)

mscb.mscb_user(fd, adr, param, size, result, rsize)

mscb.mscb_verify(fd, node_adr, sub_adr, filename, flags)

mscb.mscb_write(fd, adr, index, data, size)

mscb.mscb_write_group(fd, adr, index, data, size)

mscb.mscb_write_mem(fd, node_adr, sub_adr, mem_adr, buffer, size)

mscb.mscb_write_no_retries(fd, adr, index, data, size)

mscb.mscb_write_range(fd, adr, index1, index2, data, size)

mscb.set_mac_address(fd)

Interactively configure an Ethernet submaster like the C API helper.