8.26. modbus_rt 模块 API 文档

8.26.1. API

8.26.1.1. class data_trans(_modbus_rt._data_trans):

def reg2reg(self,val:int):...
def regs2regs(self,val:list):...
def regs2bytes(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def regs2str(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def regs2signed(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def regs2int(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def regs2uint(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def regs2long(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def regs2float(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def regs2double(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def bytes2regs(self,val:any,mode=LITTLE_ENDIAL_SWAP):...
def str2regs(self,val:str,mode=LITTLE_ENDIAL_SWAP):...
def signed2regs(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def int2regs(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def uint2regs(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def long2regs(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def float2regs(self,val:list,mode=LITTLE_ENDIAL_SWAP):...
def double2regs(self,val:list,mode=LITTLE_ENDIAL_SWAP):...

8.26.1.2. class rtu(_modbus_rt._rtu):

def __init__(self,mode=SLAVE):...
def set_serial(self,devname:str,baudrate=115200,bytesize=8,parity='N',stopbits=1,xonxoff=0):...
def set_over_type(self,over_type:int):...
def set_net(self,ip='',port=502,type=SOCK_STREAM):...
def set_ip(self,ip:str):...
def set_port(self,port:int):...
def set_type(self,type:int):...
def set_p2p(self,p2p_flag:int):...
def open(self):...
def isopen(self):...
def close(self):...
def set_addr(self,addr:int):...
def set_strict(self,strict:int):...
def add_block(self,name:str,type:int,addr:int,nums:int):...
def regs_binding(self,regs:bytes,type:int,addr:int,nums:int):...
def set_pre_ans_callback(self,cb):...
def set_done_callback(self,cb):...
def set_dev_binding(self,flag:int):...
def set_server(self,saddr:str,sport:int):...
def get_saddr(self):...
def excuse(self,dir_slave:int,type_function:int,addr:int,*val):...
def download(self,slave:int,file_dev:str,file_master:str):...
def upload(self,slave:int,file_dev:str,file_master:str):...

8.26.1.3. class ascii(rtu):

8.26.1.4. class tcp(_modbus_rt._tcp):

def __init__(self,mode=SLAVE):...
def set_net(self,ip='',port=502,type=SOCK_STREAM):...
def set_ip(self,ip:str):...
def set_port(self,port:int):...
def set_type(self,type:int):...
def set_p2p(self,p2p_flag:int):...
def open(self):...
def isopen(self):...
def close(self):...
def set_addr(self,addr:int):...
def set_strict(self,strict:int):...
def add_block(self,name:str,type:int,addr:int,nums:int):...
def regs_binding(self,regs:bytes,type:int,addr:int,nums:int):...
def set_pre_ans_callback(self,cb):...
def set_done_callback(self,cb):...
def set_dev_binding(self,flag:int):...
def set_server(self,saddr:str,sport:int):...
def get_saddr(self):...
def excuse(self,dir_slave:int,type_function:int,addr:int,*val):...
def download(self,slave:int,file_dev:str,file_master:str):...
def upload(self,slave:int,file_dev:str,file_master:str):...

8.26.2. Examples