:: Area: #0 (BBC-Micro) Message: 30208 (Read 1 time, has 0 replies, 5307 bytes) Date : Thu, 09 Aug 2007 16:24:56 +0100 From : jgh@arcade.demon.co.uk (Jonathan Graham Harston) Subject: Re: Emulating Econet hardware? Reply-To: Message-ID: <070809165506@arcade.demon.co.uk> I'm still digging away at this to fully document it... The UDP data contains an eight-byte header containing information from the Econet packet header, followed by the Econet packet data: UDP Data: +------------------+ | Magic number &02 | &02=Data packet, &03=Ack, &04=NAK | Econet Port | | Econet Control | | Padding &00 | | Handle &nnnnnnnn | |------------------| | Econet | | Packet | | Data | +------------------+ I think the Net_Tx() function in the Net library would essentially do something like the following: DEFFNNet_Tx(Stn%,Ctrl%,Port%,Addr%,Len%,RAddr%):try=10:delay=50 REPEAT /* Prepare to send */ sock=socket(AF_INET, SOCK_DGRAM, 0); name.sin_family=AF_INET; /* Internet socket */ name.sin_port=&8000; /* Port for Econet-Over-Ethernet */ name.sin_addr.s_addr=Stn% /* Destination */ header[0]=&02 /* Econet header */ header[1]=Port% header[2]=Ctrl% header[3]=0 header[4..7]=RAddr% iov[0].base=&header /* Point to header to send */ iov[0].len=8 /* Eight bytes in header */ iov[1].base=Addr% /* Point to data to send */ iov[1].len=Len% /* Specified bytes of data */ socketwritev(sock, &iov, 1); socketclose(sock); /* Now listen for an acknowledgement */ sock=socket(AF_INET, SOCK_DGRAM, 0); name.sin_family=AF_INET; /* Internet socket */ name.sin_port=&8000 /* Port for Econet-Over-Ethernet */ name.sin_addr.s_addr=Stn% /* Who we're expecting an Ack from */ bind(sock, &name, sizeof(name)); socketread(sock, buf, buflen) socketclose(sock) IF buf[0]<>3 THEN try=try-1:IF try>0 THEN PROCdelay(delaytime) UNTIL buf[0]=3 OR try<1 IF buf[0]=3 THEN =0 :REM Ok IF buf[0]=4 THEN =&42:REM Not listening =&40:REM Network error The above is completely off the top of my head, is untried, and isn't real code that will sucessfully run or compile. I'm still working out the equivalent translation for Net_RxOpen, Net_RxPoll and Net_RxRead. -- J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH BBC BASIC for 30+ platforms - http://mdfs.net/Software/BBCBasic The most perfect world is an imperfect world as the imperfections give people a reason to strive to change it. _______________________________________________ bbc-micro mailing list bbc-micro@lists.cloud9.co.uk http://lists.cloud9.co.uk/mailman/listinfo/bbc-micro