miracle2k / onkyo-eiscp

Control Onkyo A/V receivers over the network; usuable as a script, or as a Python library.
MIT License
467 stars 110 forks source link

Delay on Linux due to \r vs \n ? #95

Open kalsan opened 6 years ago

kalsan commented 6 years ago

When I send a command to Onkyo, the response time is several seconds. Until today, I thought that the receiver is just slow, but I just made an observation that might tell a different story:

Playing around with an ESP8266, I implemented a client that talks to a Linux host. The line where it reads back from the host is: String reply = client.readStringUntil('\r'); The same function is used to implement a server on embedded systems (such as the Onkyo I assume).

The observation is that the line always blocks one second. The Linux Host sends the reply immediately, but my ESP8266 woud wait an entire second before the above line terminates. Turns out that the Linux Host never sends \r (\r\n is a Windows thing) but a \n instead and the default timeout for readStringUntil is 1000ms. Changing the \r to \n caused the device to reply immediately because it didn't wait for the timeout any more.

Could it be that the slow Onkyo isn't that slow in reality? On the app, the reaction is immediate. Could it be that onkyo-eiscp sends just \n if it is run on Linux hosts but the Onkyo expects \r ?

miracle2k commented 6 years ago

Interesting. I don't have a receiver available right now to test on, but if someone could try to look into this, I'd be curious.