Attached is a little test script. Here is what it puts out:
Code: Select all
$ ./checkIO-2.py
emergency stop pressed at 2020-12-01T12:36:11.539731
emergency stop pressed at 2020-12-01T13:07:29.836058
emergency stop pressed at 2020-12-01T14:00:38.832124
emergency stop pressed at 2020-12-01T14:39:26.019836
Version information:
Code: Select all
# uname -a
Linux emibox0001 4.19.95-rt38-v7+ #1 SMP PREEMPT RT Tue, 16 Jun 2020 13:25:43 +0200 armv7l GNU/Linux
# piTest -d
Found 3 devices:
Address: 0 module type: 105 (0x69) RevPi Connect V1.0
Module is present
input offset: 113 length: 6
output offset: 119 length: 5
Address: 31 module type: 96 (0x60) RevPi DIO V1.4
Module is present
input offset: 0 length: 70
output offset: 70 length: 18
Address: 32 module type: 109 (0x6d) RevPi CON CAN V0.0
Module is present
input offset: 0 length: 0
output offset: 0 length: 0
Code: Select all
#!/usr/bin/env python3
import time
import subprocess
from datetime import datetime
def read_output(address) -> int:
pitest_output = subprocess.run(['piTest', '-q', '-1', '-r', address], stdout=subprocess.PIPE)
return int(pitest_output.stdout)
while True:
if (read_output("I_2") != 1):
dt=datetime.now()
print("emergency stop pressed at " + datetime.utcnow().isoformat())
time.sleep(0.001)