On 12/5/06, chris <[EMAIL PROTECTED]> wrote: > On Tuesday 05 December 2006 06:19, Peter Kropf wrote: > > I was poking around the owserver protocol from Python > > is that with socket or are you using higher level modules? > can you show a demo script?
And here's a version that actually works: You'll need to change the owserver host (kuro2) and port number (9999) but it displays the directory entries for root. I'll use this as a basis for a new ownet python module that provides the same object interface as the current ow module but only knows how to communicate with an owserver and doesn't depend on the rest of the core libraries. Once done, it should run on any platform supported by Python... import sys import os import socket import struct msg_error = 0 msg_nop = 1 msg_read = 2 msg_write = 3 msg_dir = 4 msg_size = 5 msg_presence = 6 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print s s.connect(('kuro2', 9999)) payload = '/' #payload = '/bus.0' # 1234567890123456 #payload='/10.B7B64D000800' print 'payload:', payload smsg = struct.pack('iiiiii', socket.htonl(0), #version socket.htonl(len(payload) + 1), #payload length socket.htonl(msg_dir), #type of function call socket.htonl(258), #format flags socket.htonl(0), #size of data element for read or write socket.htonl(0), #offset for read or write ) print 'len(smsg):', len(smsg) print 'smsg:', smsg s.sendall(smsg) smsg = payload + '\x00' print 'len(smsg):', len(smsg) print 'smsg:', smsg s.sendall(smsg) while 1: data = s.recv(24) version, payload_len, type_of_call, format_flags, size_of_data, offset = struct.unpack('iiiiii', data) version = socket.ntohl(version) payload_len = socket.ntohl(payload_len) type_of_call = socket.ntohl(type_of_call) format_flags = socket.ntohl(format_flags) size_of_data = socket.ntohl(size_of_data) offset = socket.ntohl(offset) print print 'version:', version print 'payload_len:', payload_len print 'type_of_call:', type_of_call print 'format_flags:', format_flags print 'size_of_data:', size_of_data print 'offset:', offset if payload_len: data = s.recv(payload_len) print 'payload:', data[:size_of_data] else: break s.close() sys.exit(0) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Owfs-developers mailing list Owfs-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/owfs-developers