コード例 #1
0
ファイル: pollmb.py プロジェクト: GotAudio/MBLogic-pollmb
	# Get the reply.
	try:
		Recv_TransID, Recv_Function, Recv_Data = mbclient.ReceiveResponse()
	except:
		if not BriefOutput:
			print('Error receiving data from host.')
		else:
			print('%s, %d, Error receiving data from host.' % (host, port))
		sys.exit(5)

	# Decode the reply.
	try:
		if CharacterOutput:
			hexdata = str(Recv_Data)
		elif Recv_Function in (1, 2):
			hexdata = ModbusDataStrLib.inversorbin(Recv_Data)
		elif Recv_Function in (3, 4):
			hexdata = ModbusDataStrLib.bin2hex(Recv_Data)
		elif  Recv_Function in (5, 6, 15, 16):
			hexdata = ModbusDataStrLib.bin2hex(Recv_Data)
		elif Recv_Function == 65:
			hexdata = ModbusDataStrLib.bin2hex(Recv_Data)
#[104:106] + '.' + ModbusDataStrLib.bin2hex(Recv_Data)[106:108] + '.' + ModbusDataStrLib.bin2hex(Recv_Data)[108:110] + '.' + ModbusDataStrLib.bin2hex(Recv_Data)[110:112]
		elif (Recv_Function > 127):
			hexdata = str(Recv_Data)
		else:
			hexdata = 'No Data'
	except:
		if not BriefOutput:
			print('Bad data format received from host for function %d' % Recv_Function)
		else: