
import os
import sys
import math
import codecs

import serial

sensor = serial.Serial(port='/dev/ttyAMA0', baudrate='9600', timeout=1)

def convert(hexVal):
    return int(codecs.encode(hexVal, 'hex'), 16)

while True:
    data = sensor.read(size=1)
    if (data == b'\x55'):
        print('Get the data !')
        sensor.read(size=10)
        break

    print('trying', data)

try:
    while True:
        data = sensor.read(size=11)
        if not len(data) == 11:
            print('Byte error !')
            break

        if data[1] == b'\x50':

            print(convert(data[7]))


        # Angle Output.
        if (data[1] == b'\x53'):

            pass

        '''
        if data[1] == b'\x54':

            x = convert(data[2:4])
            y = convert(data[4:6])
            z = convert(data[6:8])

            # print("Magnetic output:{}, {}, {}".format(x, y, z))

        #Angle
        
           '''

        # print("----", data[0], data[1])

except KeyboardInterrupt:
    sensor.close()
    print('Close the sensor !')

import os
import sys
import math
import codecs

import serial

sensor = serial.Serial(port='/dev/ttyAMA0', baudrate='9600', timeout=1)

def convert(hexVal):
    return codecs.encode(hexVal, 'hex')

while True:
    data = sensor.read(size=1)
    if (data == b'\x55'):
        print('Get the data !')
        sensor.read(size=10)
        break

    print('trying', data)

try:
    while True:
        data = sensor.read(size=11)
        if not len(data) == 11:
            print('Byte error !')
            break

        if data[1] == b'\x50':

          # print(convert(data[7]))
          pass

        # Angle Output.
        if (data[1] == b'\x53'):
          hexVal = []
          for i in range(11):
            hexVal.append(convert(data[i]))

          print(hexVal)

except KeyboardInterrupt:
    sensor.close()
    print('Close the sensor !')
Complete the data print interface.
Complete the data print interface.

  
  import os
  import sys
  import math
  import codecs
  
  import serial
  
  sensor = serial.Serial(port='/dev/ttyAMA0', baudrate='9600', timeout=1)
  
  def convert(hexVal):
-     return int(codecs.encode(hexVal, 'hex'), 16)
+     return codecs.encode(hexVal, 'hex')
  
  while True:
      data = sensor.read(size=1)
      if (data == b'\x55'):
          print('Get the data !')
          sensor.read(size=10)
          break
  
      print('trying', data)
  
  try:
      while True:
          data = sensor.read(size=11)
          if not len(data) == 11:
              print('Byte error !')
              break
  
          if data[1] == b'\x50':
  
-             print(convert(data[7]))
+           # print(convert(data[7]))
- 
+           pass
  
          # Angle Output.
          if (data[1] == b'\x53'):
+           hexVal = []
+           for i in range(11):
+             hexVal.append(convert(data[i]))
  
+           print(hexVal)
-             pass
- 
-         '''
-         if data[1] == b'\x54':
- 
-             x = convert(data[2:4])
-             y = convert(data[4:6])
-             z = convert(data[6:8])
- 
-             # print("Magnetic output:{}, {}, {}".format(x, y, z))
- 
-         #Angle
-         
-            '''
- 
-         # print("----", data[0], data[1])
  
  except KeyboardInterrupt:
      sensor.close()
      print('Close the sensor !')
Complete the data print interface.
## Code Before:

import os
import sys
import math
import codecs

import serial

sensor = serial.Serial(port='/dev/ttyAMA0', baudrate='9600', timeout=1)

def convert(hexVal):
    return int(codecs.encode(hexVal, 'hex'), 16)

while True:
    data = sensor.read(size=1)
    if (data == b'\x55'):
        print('Get the data !')
        sensor.read(size=10)
        break

    print('trying', data)

try:
    while True:
        data = sensor.read(size=11)
        if not len(data) == 11:
            print('Byte error !')
            break

        if data[1] == b'\x50':

            print(convert(data[7]))


        # Angle Output.
        if (data[1] == b'\x53'):

            pass

        '''
        if data[1] == b'\x54':

            x = convert(data[2:4])
            y = convert(data[4:6])
            z = convert(data[6:8])

            # print("Magnetic output:{}, {}, {}".format(x, y, z))

        #Angle
        
           '''

        # print("----", data[0], data[1])

except KeyboardInterrupt:
    sensor.close()
    print('Close the sensor !')
## Instruction:
Complete the data print interface.
## Code After:

import os
import sys
import math
import codecs

import serial

sensor = serial.Serial(port='/dev/ttyAMA0', baudrate='9600', timeout=1)

def convert(hexVal):
    return codecs.encode(hexVal, 'hex')

while True:
    data = sensor.read(size=1)
    if (data == b'\x55'):
        print('Get the data !')
        sensor.read(size=10)
        break

    print('trying', data)

try:
    while True:
        data = sensor.read(size=11)
        if not len(data) == 11:
            print('Byte error !')
            break

        if data[1] == b'\x50':

          # print(convert(data[7]))
          pass

        # Angle Output.
        if (data[1] == b'\x53'):
          hexVal = []
          for i in range(11):
            hexVal.append(convert(data[i]))

          print(hexVal)

except KeyboardInterrupt:
    sensor.close()
    print('Close the sensor !')