Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- """
- Address mapping of SMC EX260-SIL1-X210 for IO-Link
- The package rich is required to display the result in a table.
- Windows: py -3 -m pip install rich
- Linux: pip3 install rich
- """
- from itertools import count
- from rich.console import Console
- from rich.table import Table
- def get_valve_mapping(start, size):
- size //= 4
- valve = count(1)
- for byte in reversed(range(start, start + size)):
- for bit in range(8):
- yield f"M{next(valve)}", f"Q{byte}.{bit}"
- def print_valve_mapping(start, size=32):
- console = Console()
- table = Table()
- table.add_column("Valve")
- table.add_column("Address")
- for row in get_valve_mapping(start, size):
- table.add_row(*row)
- console.print(table)
- if __name__ == "__main__":
- start_address = 132
- size_bits = 16
- print_valve_mapping(start_address, size_bits)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement