Reading the network status
Rick Murray (539) 13840 posts |
Moved here from this topic. NDA my arse. You cannot hope to NDA something that’s open source. God I wish there was a tool that would use the C preprocessor to examine a file, and all of the linked files, to locate a definition of a certain variable, definition, deftype, or struct. Anyway… For the link status: SYS "EtherUSB_Stats", A, B, C where ‘A’ is either 0 to return &FF for the supported things, or 1 to return actual information. A structure is filled in (all values UNSIGNED). It has the following layout (for EtherUSB): byte +0 Interface type (see below) byte +1 Link status (see below) byte +2 Link polarity (is '1' if correct) byte +3 -- word +4 -- word +8 -- word +12 -- word +16 -- word +20 -- word +24 -- word +28 TX frames word +32 TX bytes word +36 TX general errors word +40 -- (is actually word +44 -- eight bytes) word +48 -- word +52 -- word +56 -- word +60 -- word +64 -- word +68 Jabbers (it actually sets this, but doesn't tell you it does!) word +72 -- word +76 Unwanted frames word +80 RX frames word +84 RX bytes word +88 RX general errors word +92 -- (is actually word +96 -- eight bytes) The interface type (non-exhaustive; ‘*’ means ones EtherUSB knows about): 2 10base2 3 10baseT * 7 Econet 8 Serial 12 100baseTX * 14 100baseT4 * 21 1000baseT (4 pair cat 5) The link status is built up as follows: bit 0 : OK (device functional) bit 1 : Up (link is connected) bit 2 : See below bit 3 : See below bit 4 : Set if Full Duplex Bits 2 and 3 are: Bit 3 Bit 2 Meaning 0 1 Broadcast 1 0 Multicast 1 1 Promiscuous The following will demonstrate: >*EJInfo EtherUSB driver for USB network adapters, version 0.37, by James Peacock [snip] ej0: SMSC95xx, USB bus 1, device 3, Devices:$.USB3, up [snip] Interface media : 100baseTX full duplex Interface polarity : Correct Controller mode : Multicast Packets sent : 202454 Packets received : 896505 Bytes sent : 39846858 Bytes received : 124162490 [snip] >DIM x% 127 >SYS "EtherUSB_Stats", 1, 0, x% >P. x%?0, x%?1, x%?2, x%!28, x%!32, x%!80, x%!84 12 27 1 202454 39846858 896505 124162490 Where the interface type is 100baseTX, the status bits are ‘27’ (%11011) which means (msb) Full Duplux, Multicast, Up, OK (lsb)), the polarity is correct, and you can see the Tx/Rx frames and bytes match. As this appears to be a DCI thingummy, I would imagine other EtherXXX_Stats calls would return similar information. Call with R0 = 0 and see what’s set to &FF to see what the driver thinks it will return if asked (R0 = 1). In the codebase, it’s mostly in ..bsd.RiscOS.Sources.Networking.Ethernet.EtherUSB.c.net, function net_stats (towards the bottom). |
Steve Pampling (1551) 8170 posts |
I would never call you a tool :)
See. Result in almost no time at all. |
Andrew Conroy (370) 740 posts |
You’d have to get the official word from ROOL, but last time I asked the DCI4 Spec document (which defines what each bit signifies, amongst other things) contained IP belonging to ANT Ltd and so required you to sign an NDA before you were granted permission to read it. It is possible that you could read the terms of the NDA to mean that making the OS Open Source negated the NDA, but that probably depends on how much you can afford to spend on lawyers! I’d be delighted of ROOL were to officially confirm that the DCI4 spec was no longer covered by an NDA! I can’t comment on the correctness of the rest of your post as I’m still under the NDA until 2022! |
Rick Murray (539) 13840 posts |
I can understand that back in the 90s this would potentially have made commercial sense (just off the top of my head, it’s MBufManager, right?) given that a company created certain parts of the network stack for Acorn.
Better yet, just ignore that nonsense completely. Never seen it, never signed it, just looked at the code. :-)
I know it is correct, at least for EtherUSB, because it’s what the source does. If your document disagrees, the document is wrong.
Jeez, in RISC OS terms that’s practically tomorrow. I was cleaning up the mess in the staff break room this morning. There’s a massive flat TV fixed to the wall. It was playing a channel called CSTAR, which is a DTV incarnation of MTV. Well, MTV when it used to play music videos and not all that reality crap. |
Rick Murray (539) 13840 posts |
Actually, about half an hour of just working my way through all the #include lines. Bearing in mind that header files that one includes can include others themselves.
<blush>
I was agitated by this whole NDA thing referring to something that I can see the source of. It didn’t make sense. And, besides, it’s another dark corner of the OS dusted off. I’ll leave somebody else to drop it into the documentation wiki though. I hope that come 2022 Andrew will tell us the API of MBufManager so we can exorcise another binary blob from the OS. I think the network bounty will help get rid of Resolver (given it’s not IPv6). |
Steve Pampling (1551) 8170 posts |
So, if you were to check the source and basically “reverse engineer” the spec people wouldn’t need to read a document that may not actually accurately describe the implementation anyway…
Um, raise you, search “don’t leave me driftwood on the shore” released the year I could no longer claim teen status: a more recent rendition being me on Cov station heading to the 2018 GBBF. |
Rick Murray (539) 13840 posts |
I think mom liked the Moody Blues. River of Dreams is the year that I was no longer considered a teenager. I write it like that because I have the mind of a bored teenager stuck in the body of an old fart…
Um… Guys… https://www.chiark.greenend.org.uk/~theom/riscos/docs/dci4-1.01.txt |
Chris Mahoney (1684) 2165 posts |
Me: I’ll just save that file, in case I ever need it. My computer: dci4-1.01.txt already exists; do you want to replace it? Well then… |
Andrew Conroy (370) 740 posts |
Of course, that appears to be version 1.01 of the document, whereas the version I saw was 4.07! |
Steve Pampling (1551) 8170 posts |
A 0.01 increment per spelling mistake or typo corrected would fill most of the difference I think :) |