michaelroland / wdnas-hwdaemon

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

Is DSM6.1.7 OK? #6

Open ihongyi opened 6 years ago

ihongyi commented 6 years ago

Can this support Synology? I haven't succeeded in DSM6.1.7. Can I ask you the way?

michaelroland commented 6 years ago

This software is specific to Western Digital My Cloud DLx100 and PRx100 device hardware. It would not make any sense on other platforms.

ihongyi commented 6 years ago

My hardware is pr4100. The system is Synology The system could not find the systemctl command.

ihongyi commented 6 years ago

I only found the synoservice command.

Run sudo synoservice -is-enable wdhwd.service

Prompt Service [wdhwd.service] does not exist

ihongyi commented 6 years ago

synoservice -help --help Show this help --help-dev More specialty functions for deveplopment --is-enabled [ServiceName] Check if the service is enabled --status [ServiceName] Get the status of specified services --enable [ServiceName] Set runkey to yes and start the service (alias to --start) --disable [ServiceName] Set runkey to no and stop the service (alias to --stop) --hard-enable [ServiceName] Set runkey to yes and start the service and its dependency (alias to --hard-start) --hard-disable [ServiceName] Set runkey to no and stop the service and its dependency (alias to --hard-stop) --restart [ServiceName] Restart the given service --reload [ServiceName] Reload the given service --pause [ServiceName] Pause the given service --resume [ServiceName] Resume the given service --pause-by-reason [ServiceName] [Reason] Pause the service by given reason --resume-by-reason [ServiceName] [Reason] Resume the service by given reason --pause-all (-p) [Reason] (Event) Pause all service by given reason with optional event(use -p to include packages) --pause-all-no-action (-p) [Reason] (Event) Set all service runkey to no but leave the current service status(use -p to include packages) --resume-all (-p) [Reason] Resume all service by given reason(use -p to include packages) --reload-by-type [type] (buffer) Reload services with specified type --restart-by-type [type] (buffer) Restart services with specified type Type may be {file_protocol|application} Sleep $buffer seconds before exec the command (default is 0)

stefaang commented 6 years ago

You need to make a synology service file. Are you able to run the service directly?

python -m wdhwdaemon.daemon

Do you have instructions to setup DSM on PR4100? Then I can have a look.

ihongyi commented 6 years ago

python -m wdhwdaemon.daemon Can run What is missing from the plugin setup DSM on PR4100 You need to install DSM boot on the USB Can refer to https://xpenology.com/forum/forum/31-loaders/

ihongyi commented 6 years ago

synology.txt This is the command I exported.

stefaang commented 6 years ago

I flashed the 6.2 loader to a USB drive but it didn't find the PR4100 device via find.synology.com. Please provide more detailed setup instructions if possible.

The service file is made for systemd, you need to create your own service file to match the synoservice spec. Just look at other services for examples.

ihongyi commented 6 years ago

Thank you very much for your reply Can you find the ip address of pr4100 through the router? Have you modified the vid, pid, and sn of the grub file in the 6.2 loader? If there is no sn, I can provide it to you. Sorry, my lack of knowledge about linux

ihongyi commented 6 years ago

Maybe this tool can help you https://xpenology.com/forum/topic/12422-xpenology-tool-for-windows-x64/?tab=comments#comment-88470

stefaang commented 6 years ago

Oh okay it seems there's a bit more to it... I will try it tonight.

ihongyi commented 6 years ago

Forgot to tell you that the dsm6.2 loader does not support uefi boot must be set in the BIOS boot mode is legacy only Please modify the BIOS settings and try again

ihongyi commented 6 years ago

hi @stefaang Can dsm6.2 run on your pr4100 hardware?

stefaang commented 6 years ago

Sorry.. The downtime to test this is currently too inconvenient. I may test it later when I'm sure I won't break anything.

ihongyi commented 6 years ago

Looking forward to your message

ihongyi commented 5 years ago

@stefaang Hello, is there any progress in stefaang?

stefaang commented 5 years ago

Aight... I've spend some time to set up DSM 6.1 based on this linux guide.

# sudo cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:12076 rx:0 RTS|DTR
1: uart:8250 port:000002F8 irq:3 tx:12 rx:0 RTS|DTR
2: uart:16550A mmio:0x8161E000 irq:18 tx:0 rx:0 CTS
3: uart:16550A mmio:0x8161D000 irq:19 tx:0 rx:0

As /dev/ttyS3 shows irq:19, it means no custom kernel is necessary...

echo "FAN=30\r" | sudo tee /dev/ttyS3

I still have to look into the whole syno service component, but you can use my FreeNAS script as a basis. Edit it to use /dev/ttyS3, disable the parts that don't work.

Here's how to get the temperature:

cat /sys/bus/platform/devices/coretemp.0/temp2_input
ihongyi commented 5 years ago

Hello. I tried the freenas script you wrote, but it will always prompt that the error is not working properly. How do I change it now? Have you run this script and can implement hardware control of pr4100?

stefaang commented 5 years ago

It seems doable to port this project to DSM. DSM 6.1 uses python 2.7.12.

python --version

Get python pip. Then install the requirements

sudo pip install pyserial smbus2

Checkout the python27 branch of this project. Apply the fixes of my previous merge requests (the one for group) In wdhwlib/temperature.py, edit the smbus import

import smbus2 as smbus

and update the coretemp base.

_CORETEMP_FILENAME_BASE = "/sys/bus/platform/devices/coretemp.0/temp{0:d}_{1}"

Edit the wdhwd.conf to run as root and on the correct port, no disks, no dimms ... and it runs like a champ.

Probably a few more minor things to get it to run automatically on boot. I'll make a branch in my repo with all the required changes when I'm in a good mood.

ihongyi commented 5 years ago

Thank you, I tried to give it a try.

stefaang commented 5 years ago

I made an install script for wdhw-tools tested on DSM 6.1.7.

wget https://github.com/WDCommunity/wdnas-hwtools/archive/dsm.tar.gz
tar xf dsm.tar.gz && cd wdnas-hwtools-dsm
sudo ./dsm_install.sh
sudo /usr/local/etc/rc.d/wdhwd.sh start

Interact with the client

sudo wdhwc --help
ihongyi commented 5 years ago

Running sudo ./dsm_install.sh to the last error ./dsm_install.sh: line 27: /usr/local/sbin/wdhwc: No such file or directory Chmod: cannot access ‘/usr/local/sbin/wdhwc’: No such file or directory

ihongyi commented 5 years ago

After manually creating the sbin directory, the led is normal. lcd has no display.

ihongyi commented 5 years ago

sudo /usr/local/etc/rc.d/wdhwd.sh start sudo: /usr/sbin/hddtemp: command not found /usr/local/share/wdhwd/scripts/system_up.sh: line 31: /usr/sbin/sendmail: No such file or directory

stefaang commented 5 years ago

Changes:

ihongyi commented 5 years ago

hello stefaang
The path to smartctl should be /usr/bin instead of /usr/sbin

I now run sudo /usr/local/etc/rc.d/wdhwd.sh start will output Root@ABC-NAS:~# sudo /usr/local/etc/rc.d/wdhwd.sh start Root@ABC-NAS:~# 2018-11-24 20:32:46,021 - main - ERROR - WdHwDaemon: Daemon failed with PMCCommandTimeoutError: No response received before timeout was reac hed; exiting /usr/local/share/wdhwd/scripts/system_down.sh: line 31: /usr/sbin/sendmail: No s uch file or directory Traceback (most recent call last):   File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main     "main", fname, loader, pkg_name)   File "/usr/lib/python2.7/runpy.py", line 72, in _run_code     Exec code in run_globals   File "/usr/local/share/wdhwd/wdhwdaemon/daemon.py", line 925, in     Ret = d.main(sys.argv)   File "/usr/local/share/wdhwd/wdhwdaemon/daemon.py", line 814, in main     Pmc_version = pmc.getVersion()   File "wdhwlib/wdpmcprotocol.py", line 417, in getVersion     Return self.__processor.transceiveCommand(_PMC_COMMAND_VERSION)   File "wdhwlib/wdpmcprotocol.py", line 350, in transceiveCommand     (response_code, response_value) = self.sendCommandAndWaitForResponse(comma nd)   File "wdhwlib/wdpmcprotocol.py", line 319, in sendCommandAndWaitForResponse     Raise PMCCommandTimeoutError("No response received before " wdhwlib.wdpmcprotocol.PMCCommandTimeoutError: No response received before timeou t was reached And the LCD still has no display

ihongyi commented 5 years ago

Dsm can't find the sendmail command Only found these 4 commands about mail Syno_disk_smart_mail_send Synoabnormalloginmail Synopasswordmail Synosyslogmail

stefaang commented 5 years ago

I'm no longer running DSM, I thought the smartctl path would be same as on debian. I said in the previous post that you still need to write & configure the scripts yourself... e.g. remove the whole sendmail part and put something like this instead

wdhwc lcd -t "Hello\n     World"
ihongyi commented 5 years ago

Which file is written?

ihongyi commented 5 years ago

I now run sudo /usr/local/etc/rc.d/wdhwd.sh start will output Root@ABC-NAS:# sudo /usr/local/etc/rc.d/wdhwd.sh start Root@ABC-NAS:# 2018-11-24 20:32:46,021 - main - ERROR - WdHwDaemon: Daemon failed with PMCCommandTimeoutError: No response received before timeout was reac hed; exiting /usr/local/share/wdhwd/scripts/system_down.sh: line 31: /usr/sbin/sendmail: No s uch file or directory Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "/usr/lib/python2.7/runpy.py", line 72, in _run_code Exec code in run_globals File "/usr/local/share/wdhwd/wdhwdaemon/daemon.py", line 925, in Ret = d.main(sys.argv) File "/usr/local/share/wdhwd/wdhwdaemon/daemon.py", line 814, in main Pmc_version = pmc.getVersion() File "wdhwlib/wdpmcprotocol.py", line 417, in getVersion Return self.__processor.transceiveCommand(_PMC_COMMAND_VERSION) File "wdhwlib/wdpmcprotocol.py", line 350, in transceiveCommand (response_code, response_value) = self.sendCommandAndWaitForResponse(comma nd) File "wdhwlib/wdpmcprotocol.py", line 319, in sendCommandAndWaitForResponse Raise PMCCommandTimeoutError("No response received before " wdhwlib.wdpmcprotocol.PMCCommandTimeoutError: No response received before timeou t was reached

Can these errors be ignored?

stefaang commented 5 years ago

Make sure that it's running only once

ps aux | grep wdhwd

Kill -9 the other pids if necessary.

ihongyi commented 5 years ago

Sorry, I don't know what file to modify to configure lcd Please tell me the file name

ihongyi commented 5 years ago

Just need to modify client.py?

stefaang commented 5 years ago

The scripts to run on system_up/down, button pressed... are defined in /etc/wdhwd.conf. So you need to modify the scripts in the scripts directory. Quite obvious, no?

ihongyi commented 5 years ago

Sorry, I don't have any knowledge in this area. Would you please help me with an example? Just show any text on the lcd. I will try to change it.

ihongyi commented 5 years ago

Is it because I can't find a command that can replace sendmail?

stefaang commented 5 years ago

Here's how to set something on the LCD: https://github.com/WDCommunity/wdnas-hwtools/blob/master/scripts/system_up.sh#L24-L27 The upcoming days I can add examples to make it behave like the original LCD.

I don't use sendmail... you'll have to sort that out yourself, sorry...

ihongyi commented 5 years ago

I am looking forward to your example. I have successfully shown the LCD just now. Thank you Can DSM also use buttons? Includes fan control and hard drive information

ihongyi commented 5 years ago

I can't find /button_pressed.sh and button_pressed.sh in the scripts directory. Is this why I can't use the button? Did you forget to add these two files?

stefaang commented 5 years ago

Changes:

  • Added basic LCD and buttons support (but you still need to write the scripts yourself)
ihongyi commented 5 years ago

Thanks, I know, these two scripts need to be written by myself. Now I can only wait for your example.

ihongyi commented 5 years ago

Can you also make your updates available to dsm?

ihongyi commented 5 years ago

I have been following your steps

ihongyi commented 5 years ago

After I used your update in the dsm branch, the LED LCD is now out of control. Is it what I did wrong?

ihongyi commented 5 years ago

Daemon.py 476 lines Please fix

ihongyi commented 5 years ago

Now press the button will output Client.py: error: unrecognized arguments: address\n192.168.0.100 Usage: client.py [-h] [-C [CONFIG_FILE]] [-v] [-q] [-V] COMMAND ... Client.py: error: unrecognized arguments: Disk Usage\n1.2G free 49% used Usage: client.py [-h] [-C [CONFIG_FILE]] [-v] [-q] [-V] COMMAND ... Client.py: error: unrecognized arguments: temperature\n 29 °C

stefaang commented 5 years ago

Fixed daemon.py typo. Please save me some time by adding a full link in the future. Just click the line in the source code on github. Client errors mean outdated wdhwc client. Run the installer again.

You are free to fork and submit patches yourself...

git clone https://github.com/WDCommunity/wdnas-hwtools
git checkout dsm
git checkout -b somebug
# fix the bug
git commit -am 'Fixed typo whatever'
git push
# make merge request to dsm branch.
ihongyi commented 5 years ago

Now you can use the button to switch the lcd display. But will output Traceback (most recent call last):    File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main      "main", fname, loader, pkg_name)    File "/usr/lib/python2.7/runpy.py", line 72, in _run_code      Exec code in run_globals    File "/usr/local/share/wdhwd/wdhwdaemon/client.py", line 505, in      Ret = c.main(sys.argv)    File "/usr/local/share/wdhwd/wdhwdaemon/client.py", line 453, in main      conn.setLCDText(2, line2)    File "/usr/local/share/wdhwd/wdhwdaemon/client.py", line 151, in setLCDText      Parameter.extend(text.encode('us-ascii', 'ignore')) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 14: ordinal not in range(128)

ihongyi commented 5 years ago

Temperature cannot be displayed now

stefaang commented 5 years ago

Try to change that line to

parameter.extend(text.decode('us-ascii', 'ignore'))

EDIT: why put title case in stack traces?