If it is needed, I'd be really interested to figure out why so I can correct it on the firmware side. No reason you guys should have to work with a half-working LocalTalk transceiver...For the reset, if it is needed, we can add it in the open() and maybe add an ioctl for it.
I'm really perplexed about this. TashTalk's receiver does not just interpret line noise as framing errors. Even if the line is floating when idle, there would have to be inversions detected on the line that look like a zero followed by a series of seven ones. Need to get some scope traces...The "frame error" is 0x00 0xFE. I always get plenty of those, particularly when the line is idle. I thought it was because of the sketchiness of my setup (I hacked the internal modem port of my PB100 and I'm to lazy to add a pull-up after buffer, so I think the input to TashTalk floats), but if you have them also I'm unsure what they can be.
It's a bit of a hack, but you could have the driver regularly send out ENQs for all 254 possible addresses and build and keep a map of which addresses are in use. Then SIOCSIFADDR could return immediately because it would know whether the requested address is in use or not.At this stage I still miss node id arbitration, which is the next thing to add. I'm not 100% sure how to implement it, since netatalk expects it to be synchronous: it does an SIOCSIFADDR and SIOCGIFADDR back-to-back, and the SIOCSIFADDR is blocking while arbitrating the address. If I understand correctly, the COPS driver tries to get the address suggested by netatalk via SIOCSIFADDR, and blocks until finished. Then netatalk calls SIOCGIFADDR to get the actual address (the suggested one or another).
The default algorithm for AppleTalk Node ID allows for a "hint", which is usually the last configured Node ID for the host. Basically atalkd is trying to quickly acquire a Node ID since the odds are high the last one used is still free. The following SIOCGIFADDR is to catch if the address changed due to a conflict. It isn't doing anything out of the ordinary.At this stage I still miss node id arbitration, which is the next thing to add. I'm not 100% sure how to implement it, since netatalk expects it to be synchronous: it does an SIOCSIFADDR and SIOCGIFADDR back-to-back, and the SIOCSIFADDR is blocking while arbitrating the address. If I understand correctly, the COPS driver tries to get the address suggested by netatalk via SIOCSIFADDR, and blocks until finished. Then netatalk calls SIOCGIFADDR to get the actual address (the suggested one or another). I will need to see how to reproduce this. I also miss ENQ and ACK managing but that should be easy.
It's custom with drivers to reset any found hardware to a "known" state during loading and initialization. It's good practice. The one corner case I'm concerned about is what is still in the Tx buffers if I terminate the serial line discipline with Ctrl-C and then restart it. Blasting it with null characters solves the problem.If it is needed, I'd be really interested to figure out why so I can correct it on the firmware side. No reason you guys should have to work with a half-working LocalTalk transceiver...
Oh, during loading and initialization is fine, I was worried you meant periodically during normal operation.It's custom with drivers to reset any found hardware to a "known" state during loading and initialization.
I expect the input to idle high on both TashTalk 1.x and 2.x. It might be okay for it to idle low, too, but I'm not sure, I need to dig into the code again...Quick question: on TashTalk 1 the LocalTalk input should be idle low or high?
It seems strange to me that that could cause a framing error, but I suppose we'll see what happens...I suspect that is what generates the frame errors on my system.
If you narrow down an obvious bug in afpd please don't hesitate to file a ticket and/or PR with the upstream project. https://github.com/Netatalk/netatalk/issuesYes afpd seems to do some weird stuff with permissions, I will have a look there later, for the moment I want to make sure the driver is working, finish up what is missing, and clean it up. BTW I merged you patch, many thanks!