michaelroland / wdnas-hwdaemon

Hardware Controller for Western Digital My Cloud NAS Systems
GNU General Public License v3.0
13 stars 10 forks source link

Errors while starting the deamon #3

Closed Friday13th87 closed 6 years ago

Friday13th87 commented 6 years ago

after installing the hwtools i am getting some errors in deamon.py and wdpmcprotocol.by i used the files from July 28

/usr/local/lib/wdhwd$ sudo python3 -m wdhwdaemon.daemon

2018-07-30 13:39:51,747 - __main__ - ERROR - WdHwDaemon: Daemon failed with PMCCommandRejectedException: ; exiting
Traceback (most recent call last):
  File "/usr/lib/python3.5/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/wdhwd/wdhwdaemon/daemon.py", line 915, in <module>
    ret = d.main(sys.argv)
  File "/usr/local/lib/wdhwd/wdhwdaemon/daemon.py", line 802, in main
    pmc_version = pmc.getVersion()
  File "/usr/local/lib/wdhwd/wdhwlib/wdpmcprotocol.py", line 428, in getVersion
    return self.__processor.transceiveCommand(_PMC_COMMAND_VERSION)
  File "/usr/local/lib/wdhwd/wdhwlib/wdpmcprotocol.py", line 351, in transceiveCommand
    raise PMCCommandRejectedException()
wdhwlib.wdpmcprotocol.PMCCommandRejectedException
michaelroland commented 6 years ago

Could you run the daemon with maximum logging verbosity and post the results?

$ sudo python3 -m wdhwdaemon.daemon -vvv
Friday13th87 commented 6 years ago

With some help i made following:

sudo python3 import serial s = serial.Serial('/dev/ttyS2') s.write(b'STA\r') # edit: used to be r'STA\r' ... but it should be bytes, not a regex s.readline()

output:

>>> s.write(r'STA\r') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3/dist-packages/serial/serialposix.py", line 518, in write d = to_bytes(data) File "/usr/lib/python3/dist-packages/serial/serialutil.py", line 63, in to_bytes raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq)) TypeError: unicode strings are not supported, please encode to bytes: 'STA\\r'

then i made >>> s.write(r'STA\r'.encode()) Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 's' is not defined

and afterwards it was working probably...

the daemon is starting now without any problems.

My System is WD PR2100 and locales are de_DE UTF-8

michaelroland commented 6 years ago

The code above seems to be your testing directly on the serial line only.

Friday13th87 commented 6 years ago

i changed the port name to ttyS2, the hwmon0 line in temperature.py to hwmon1 and thats it and some changes in my system.

michaelroland commented 6 years ago

It's still interesting that you initially got a PMCCommandRejectedException for the getVersion command. I assume you got that when using /dev/ttyS2 already, right? Or did you get that when running on port /dev/ttyS0? Also, are you running any original Western Digital tools on the device? And does the daemon still work once you removed and re-attached the power cable?

Friday13th87 commented 6 years ago

no it was already running on port ttyS2. i was able to spin down the fan with echo -ne 'STA\r' | sudo tee /dev/ttyS2 echo -ne 'FAN=25\r' | sudo tee /dev/ttyS2 echo -ne 'LN1=Cool Story Bro\r' | sudo tee /dev/ttyS2 echo -ne 'LN2=--------------\r' | sudo tee /dev/ttyS2

when i started the daemon the result was a direct fan spin up and shutdown

Friday13th87 commented 6 years ago

using the ".encode()" line changed the output even the command was wrong with an "r" instead of an "b" (s.write(b'STA\r'))

michaelroland commented 6 years ago

"r" is not entirely wrong. It doesn't mark a regex as you assumed, but instead indicates a raw string literal. And that's why r'STA\r' won't work. In a raw string literal a backslash is treated as just what it is (a "\" character) and not as the start of an escape sequence ("\r" for a carriage return character).

Friday13th87 commented 6 years ago

ok i turned the NAS down now, plugged the power cable off, waited 20 seconds and restarted the NAS. Fan controll is still working. i dont have any other WD stuff running. debian is installed on a partition of the HDDs

Friday13th87 commented 6 years ago

If you look in this thread https://community.wd.com/t/guide-how-to-install-debian-linux-on-the-my-cloud-pr4100-nas/217141/28

there are more informations and the User "Tfl" made it possible for me to use my PR2100 with debian and Fan Controll

Friday13th87 commented 6 years ago

and thank you very much for your help and for your work