import serial
import io

ser = serial.Serial(port='com29', baudrate=9600, timeout=1)

ser.isOpen()

for x in range (0, 1):
    ser.write("/Logging/StartMissionDefine\r\n".encode())
    print(ser.readline())
    ser.write("/Logging/AppendMissionCmd \"null\"\r\n".encode())
    print(ser.readline())
    #ser.write("/Logging/AppendMissionCmd \"/Timestamp/SetSource 0\"\r\n".encode())
    #print(ser.readline())
    ser.write("/Logging/AppendMissionCmd \"/MAX30001/ECG_InitStart 01 01 01 00 02 03 1F 02 00 00 01\"\r\n".encode())
    print(ser.readline())
    ser.write("/Logging/AppendMissionCmd \"/MAX30001/Rbias_FMSTR_Init 00 02 01 01 00\"\r\n".encode())
    print(ser.readline())
    ser.write("/Logging/AppendMissionCmd \"null\"\r\n".encode())
    print(ser.readline())
    ser.write("/Logging/EndMissionDefine\r\n".encode())
    print(ser.readline())
    ser.write("/Logging/WriteMission\r\n".encode())
    print(ser.readline())

ser.close()
