[sw][matcha] Update demo script for new server setup Change-Id: Ie9d8a9f981f9e9e1fa033efbe5737e5e319ab042
diff --git a/util/run_live_cam.py b/util/run_live_cam.py index be825c0..b95da87 100644 --- a/util/run_live_cam.py +++ b/util/run_live_cam.py
@@ -12,22 +12,22 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -""" -Run a live camera stream from Nexus board +"""Run a live camera stream from Nexus board """ import argparse from datetime import datetime from functools import reduce import re -import serial import subprocess +import serial from PIL import Image, ImageDraw, ImageFont def main(): """Args: smc_uart_port: SMC uart port + usb_serial: USB serial baudrate: Baud rate of smc uart input_shape: Input image shape input_mode: Input image mode @@ -35,10 +35,9 @@ parser = argparse.ArgumentParser( description='Generate inputs for ML models.') parser.add_argument("--smc_uart_port", - "-p", - dest='port', required=True, help="SMC uart port") + parser.add_argument("--usb_serial", required=True, help="USB serial") parser.add_argument("--baudrate", "-b", default=115200, @@ -58,7 +57,7 @@ parser.add_argument("--opentitantool_conf", type=str, required=True) args = parser.parse_args() - ser = serial.Serial(port=args.port, baudrate=args.baudrate) + ser = serial.Serial(port=args.smc_uart_port, baudrate=args.baudrate) while True: line = ser.readline() @@ -71,17 +70,17 @@ address = re.search(r"\[SMC\] Start of a frame, address (\d+)\.", line.decode()) if address: - address = address.groups(1)[0] + address = address.groups(1)[0] else: - continue + continue current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") print("Start loading the frame") # Load the frame from uart byte_size = str(reduce(lambda x, y: x * y, args.input_shape)) byte_str = subprocess.check_output([ args.opentitantool_bin, '--conf', args.opentitantool_conf, - '--interface', 'nexus', 'spi', 'read-memory', '--length', - byte_size, '--start', address + '--interface', 'nexus', '--usb-serial', args.usb_serial, 'spi', + 'read-memory', '--length', byte_size, '--start', address ]) im_obj = Image.frombytes(mode=args.input_mode,