def main(): rct.init(sys.argv) clientsocket = rct.connect_to_server() if clientsocket is not None: fmt = '#0x{:08X} {:'+str(rct.param_len)+'}'# {:'+str(rct.desc_len)+'}:' for obj in rct.id_tab: if rct.search_id > 0 and obj.id != rct.search_id: continue if rct.search_name is not None and fnmatch.fnmatch(obj.name, rct.search_name) == False: continue value = rct.read(clientsocket, obj.id) if rct.dbglog(fmt.format(obj.id, obj.name), value) == False: print(value) rct.close(clientsocket) sys.exit(0)
def Main(): rct.init(sys.argv) try: serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) serversocket.bind((rct.host, 8899)) serversocket.listen(5) # become a server socket, maximum 5 connections except: rct.errlog('unable to connect to', rct.host, 'port', rct.port) sys.exit(0) rct.dbglog('waiting for client connection') while True: connection, address = serversocket.accept() rct.dbglog('connection accepted', connection, address) # Start a new thread and return its identifier start_new_thread(socket_thread, (connection, address)) #socket_thread(connection, address) serversocket.close()
def main(): rct.init(sys.argv) clientsocket = rct.connect_to_server() if clientsocket is not None: for obj in rct.id_tab: if rct.search_id > 0 and obj.id != rct.search_id: continue if rct.search_name is not None and fnmatch.fnmatch( obj.name, rct.search_name) == False: continue value = rct.read(clientsocket, obj.id) if rct.dbglog( '#{:3} 0x{:08X} {:45} {:75}:'.format( obj.idx, obj.id, obj.name, obj.desc), value, obj.unit) == False: print value rct.close(clientsocket) sys.exit(0)