from m5stack import *
from m5ui import *
from uiflow import *
from machine import ModbusSlave
import i2c_bus
import unit
from numbers import Number
from micropython import const
#ATOM_modbus_slave+RFID  14.07.2020

modbus_s = ModbusSlave(1, 1, 115200, 25, 21)

fun = None
REG_addr = None
tmp_data = None
var = None

#sys vars
run_cnt = None
#RFID vars
RFID_ID = None
TAG_Reg0 = None
TAG_near = None
# ATOM PORT IO
RS485_UART = (1, 25, 21)  # TX,RX
IIC_PORTA = (26, 32)  # I2C  for 16BV demo
unit.PORTA = (
    26, 32
)  # seems used in the unit init!unit.get(unit.RFID, unit.PORTA) # fit ATOM?
#i2c0  = i2c_bus.easyI2C((25, 21), 0x28)
print('< Intelligent 16-BV connector with RS485 Port & NFC program v1.6 >' +
Example #2
0
from m5ui import *
from uiflow import *
from machine import ModbusSlave
from machine import UART
import i2c_bus
import unit
from numbers import Number
from micropython import const
#V0.7 added Modbus_RTU_MasterMsg_parse function, test ok
#SLave address+Func.code+Reg_addr(2B)+number of Words(2B)+CRC(lo first, 2B) = 8 B
#V0.5, Modbus RTU slave is working, send 9 bytes: SL_add+funct_number+len+NUID_data(4B)+CRC(2B)
#V0.4, Modbus slave is working, send 13 bytes: SL_add+funct_number+len+data(8B)+CRC(2B)
#15.07.2020 author: ling ZHOU
#(Slave_address, uart_port,tx,rx)
#modbus_s = ModbusSlave(1, 1, 115200, 25, 21)
modbus_s = ModbusSlave(1, 2, 115200, 22, 19)
uart = machine.UART(1, tx=25, rx=21)  # for 16BV module
#uart = machine.UART(1, tx=26, rx=32) # for Tail485 module
uart.init(115200, bits=8, parity=None, stop=1)

#RS485 modbus RTU
Slave_add = 0x01
Func_readID = 0x03
fun = None
REG_NUID = 0x01
ID_len = 0x04
REG_addr = None
tmp_data = None
var = None

#sys vars
Example #3
0
from m5stack import *
from m5ui import *
from uiflow import *
from machine import Modbus
from machine import ModbusSlave

rgb.set_screen([])

modbus_s = ModbusSlave(_AF9_5EaoeXNU9_60_5E_BsS8_, 1, 115200, 26, 32)

Slave_add = None
RTU_funct = None
value_rx_tmp = None
REG_0 = None


def modbus_recv_cb(x):
    global Slave_add, RTU_funct, value_rx_tmp, REG_0
    Slave_add, RTU_funct, value_rx_tmp = x.read()
    label_Slave_add.setText(str(Slave_add))
    Funct.setText(str(RTU_funct))
    Data.setText(str(value_rx_tmp))

    pass


modbus.set_recv_cb(modbus_recv_cb)


def buttonA_wasPressed():
    global Slave_add, RTU_funct, value_rx_tmp, REG_0