mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-08-30 14:52:51 +08:00
updates based upon vDorst's feedback.
change i2c_read_rtl_gpio sleep tiemr to 1s update README.md Sorted port speed
This commit is contained in:
@@ -110,11 +110,16 @@ All scripts require:
|
||||
- Python 3
|
||||
- `smbus2` Python package
|
||||
|
||||
Install with:
|
||||
(Depend upon Linux distribution) Install with:
|
||||
```bash
|
||||
pip3 install python3-smbus2
|
||||
```
|
||||
OR
|
||||
```bash
|
||||
pip3 install smbus2
|
||||
```
|
||||
|
||||
|
||||
## Common Use Cases
|
||||
|
||||
Both `i2c_read_rtl_gpio.py` and `i2c_dump_rtl_regs.py` shall run with the **original** firmware, not RTLPlayground firmware.
|
||||
|
||||
@@ -41,26 +41,26 @@ print(f"{' '.join(ledstr)}")
|
||||
print(f".led_mux = {{ 0x{', 0x'.join(ledstr)} }},")
|
||||
|
||||
LED_TYPES = [
|
||||
" 2G5",
|
||||
" TWO_1G",
|
||||
" 1G",
|
||||
" 500M",
|
||||
" 100M",
|
||||
" 10M",
|
||||
" LINK",
|
||||
" LINK_FLASH",
|
||||
" ACT",
|
||||
" RX",
|
||||
" TX",
|
||||
" COL",
|
||||
" DUPLEX",
|
||||
" TRAINING",
|
||||
" MASTER",
|
||||
"",
|
||||
" 10G",
|
||||
" TWO_5G",
|
||||
" 5G",
|
||||
" TWO_2G5",
|
||||
" 10G", 16,
|
||||
" TWO_5G", 17,
|
||||
" 5G", 18,
|
||||
" TWO_2G5", 19,
|
||||
" 2G5", 0,
|
||||
" TWO_1G", 1,
|
||||
" 1G", 2,
|
||||
" 500M", 3,
|
||||
" 100M", 4,
|
||||
" 10M", 5,
|
||||
" LINK", 6,
|
||||
" LINK_FLASH", 7,
|
||||
" ACT", 8,
|
||||
" RX", 9,
|
||||
" TX", 10,
|
||||
" COL", 11,
|
||||
" DUPLEX", 12,
|
||||
" TRAINING", 13,
|
||||
" MASTER", 14,
|
||||
"", 15,
|
||||
]
|
||||
|
||||
led_set = []
|
||||
@@ -76,8 +76,8 @@ for i in range(4):
|
||||
val += valhi
|
||||
idval.append(val)
|
||||
valstr = "("
|
||||
for bit in range(20):
|
||||
if val & (1<<bit):
|
||||
for bit in range(0,len(LED_TYPES),2):
|
||||
if val & (1<<(LED_TYPES[bit+1])):
|
||||
valstr += LED_TYPES[bit]
|
||||
valstr += ")"
|
||||
idvalstr.append(valstr)
|
||||
|
||||
@@ -9,10 +9,10 @@ from smbus2 import SMBus, i2c_msg
|
||||
I2C_BUS = 1
|
||||
DEVICE_ADDR = 0x5C # Replace with your device address
|
||||
NUM_BYTES = 8 # Bytes to read
|
||||
SLEEP_INTERVAL = 2
|
||||
SLEEP_INTERVAL = 1
|
||||
|
||||
# Handle command line arguments for ignored IOs
|
||||
IGNORED_IOS = [ 28, 31, 34, 44]
|
||||
IGNORED_IOS = [ ]
|
||||
|
||||
# Setup argument parser
|
||||
parser = argparse.ArgumentParser(description='Read I2C data from RTL GPIO expander')
|
||||
@@ -21,7 +21,7 @@ parser.add_argument('--i2c-bus', '-b', type=int, default=1,
|
||||
parser.add_argument('--sleep-interval', '-s', type=int, default=2,
|
||||
help='Sleep interval in seconds (default: 2)')
|
||||
parser.add_argument('--ignored-ios', '-i', nargs='*', type=int, default=[28, 31, 34, 44],
|
||||
help='List of GPIO pins to ignore (default: [28, 31, 34, 44])')
|
||||
help='List of GPIO pins to ignore (default: [])')
|
||||
args = parser.parse_args()
|
||||
I2C_BUS = args.i2c_bus
|
||||
SLEEP_INTERVAL = args.sleep_interval
|
||||
@@ -66,4 +66,4 @@ with SMBus(I2C_BUS) as bus:
|
||||
deltastr += f"\n{' ':8s}GPIO{idx}"
|
||||
# deltastr = " ".join([ f"{x:02x}" for x in delta_data])
|
||||
print(f"{addr:04x}: {datastr}{deltastr}")
|
||||
time.sleep(SLEEP_INTERVAL)
|
||||
time.sleep(SLEEP_INTERVAL)
|
||||
|
||||
Reference in New Issue
Block a user