import Pass as p import time as t if __name__ == '__main__': # # Listen on CAN for frames defined in DBC file # NOTE! In this mode we can only log data # # Load DBC network config file and use the default CAN device dbcFiles = [r"C:\Repos\sumac\Test试\OBDX.dbc"] p.loadDbcNetworkConfiguration(dbcFiles, 'obdx', '', 500000) dbc_vars = [ "obdx.BattVolt", "obdx.Counter200ms", "obdx.YellowTemp" ] xcp_vars = [] # XCP is empty in this example p.startDaq(xcp_vars, p.TimestampSource.SLAVE_WHEN_AVAILABLE, dbc_vars) value = p.getLatestMeasurementSample("obdx.Counter200ms") print("Last value:", value) # Filetype can be CSV or MDF p.activateRecording(p.RecorderType.CSV, 2.0) # Actually start logging data print("Start Recording") p.startRecording() # Sleep while logging # This is only for pausing the Python script sleep_time = 1.0 print("Sleep %.01f seconds" % sleep_time) t.sleep(sleep_time) # Stop and store p.stopRecording() p.saveRecording(r"c:\tmp\recording.csv") p.disconnectFromXcpSlave()