[Synology] ClearRO – 修正 Synology Drive/CloudStation 無法同步問題

在使用 Synology Drive/CloudStation 同步時,如果本地端檔案屬性為唯讀時將造成同步失敗。

ClearRO 是我寫的一個在背景中 (tray) 執行的小程式,用來處理 Drive/CloudStation 同步因為唯讀造成失敗的問題。下載後直接執行即可,不需安裝。

clearro1101.zip 執行檔下載

clearro1101_src.zip 原始碼下載 (使用 MSVS 2017)

[Ubuntu] 在桌面/Dock bar建立應用程式捷徑

在 ~/Desktop 資料夾下新增一個副檔名為 .desktop 的文字檔

gedit ~/Desktop/SlickEdit.desktop

檔案內容如下:

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=/opt/slickedit-pro2016/bin/vs
Name=SlickEdit
Comment=SlickEdit
Icon=/opt/slickedit-pro2016/bin/vs.xpm

咖啡色字體部份依照要建立捷徑的程式修改。 繼續閱讀 “[Ubuntu] 在桌面/Dock bar建立應用程式捷徑”

[Synology NAS] 同步 iTunes 與 Audio Station 音樂播放清單 (新)

2019/03/14 更新 – 使用 Docker

因為個人習慣在電腦上使用 iTunes 整理音樂,在手機使用 Synology Audio Station (DS Audio) 播放音樂,透過 Synology Drive 同步音樂或是直接將 iTunes Library 設在 NAS 都可以達到 iTunes 與 Audio Station 音樂檔案保持同步,可是有個問題,那就是在 iTunes 建立的音樂播放清單如何讓 Synology Audio Station 使用呢?為了解決這個問題我寫了一個 PHP 小程式 (ilx2sasp – iTunes Library XML 2 Synology Audio Station Playlists) 來做轉換的工作。ilx2sasp 可以將 iTunes 音樂播放清單轉成 Audio Station 可用的音樂播放清單,因為 iTunes 本身的原因所以只達到單向同步 (iTunes -> Audio Station) 而無法雙向同步。

這裏簡單說明一下 ilx2sasp 的工作原理,ilx2sasp 只是單純去解析 iTunes Library XML 中的播放清單,跟據 XML 內容將其轉成 Aduio Station 的播放列表格式 m3u 檔案。 繼續閱讀 “[Synology NAS] 同步 iTunes 與 Audio Station 音樂播放清單 (新)”

[Ubuntu] 切換 kernel 版本

首先在 http://kernel.ubuntu.com/~kernel-ppa/mainline/  選擇要切換的版本,接下來根據 CPU 架構選擇下載  .deb 檔案,例如 4.15 AMD64 版本可以看到有5個 .deb 可下載:

Build for amd64 succeeded (see BUILD.LOG.amd64):
  linux-headers-4.15.0-041500_4.15.0-041500.201802011154_all.deb
  linux-headers-4.15.0-041500-generic_4.15.0-041500.201802011154_amd64.deb
  linux-headers-4.15.0-041500-lowlatency_4.15.0-041500.201802011154_amd64.deb
  linux-image-4.15.0-041500-generic_4.15.0-041500.201802011154_amd64.deb
  linux-image-4.15.0-041500-lowlatency_4.15.0-041500.201802011154_amd64.deb

其中 -lowlatency 是低延遲版本的 kernel,除了 lowlatency 之外還有 -generic、 -rt 、 -preempt 等,沒特殊要求選擇 -generic 就行。 繼續閱讀 “[Ubuntu] 切換 kernel 版本”

[Synology] 利用反向代理伺器突破公司對埠5000/5001的封鎖

所謂反向代理伺服器 (Reverse Proxy Server) 就是反向動作的 proxy server,proxy server 的工作是去各個 web server 抓取資料回來放在伺服器供用戶讀取、下載,而反向代理伺服器做的事則相反,負責將用戶端的資料傳給藏在反向代理伺服器後的 web server,用戶端透過反向代理伺服器傳送與接收資料。

Synology DSM 預設使用 port 5000 (http) 與 5001 (https), 如果在公司想連回家中 NAS ,在 port 5000/5001 沒被封鎖的情況下,可以直接在網址要輸入 http://your_domain:5000。

可是 port 5000/5001 被公司防火牆封鎖怎麼辨?

一般來說大約有四個方法: 繼續閱讀 “[Synology] 利用反向代理伺器突破公司對埠5000/5001的封鎖”

[Ubuntu] 通用 I/O driver sample code

Ubuntu 18.04

通用型 I/O module source code (Makefile, giodrv.h, giodrv.c),測試程式顯示 Super I/O temperature sensor 温度 (Fintek F71889A):

# Makefile
KVERSION := $(shell uname -r)

obj-m := giodrv.o

all:
	$(MAKE) -C /lib/modules/$(KVERSION)/build M=${PWD} modules

clean:
	$(MAKE) -C /lib/modules/$(KVERSION)/build M=${PWD} clean

繼續閱讀 “[Ubuntu] 通用 I/O driver sample code”

[Ubuntu] 查看 device 支援的 ACPI wakeup 狀態

Ubuntu 18.04

/proc/acpi/wakeup 記錄了各 device 支援的 ACPI wakeup 狀態 (S0/S3/S4/S5),以及 wakeup function 是否啟動 (enabled/disabled):

$ cat /proc/acpi/wakeup
Device	S-state  Status   Sysfs node
EHC1	  S3	*enabled   pci:0000:00:1d.0
EHC2	  S3	*enabled   pci:0000:00:1a.0
HDEF	  S0	*disabled  pci:0000:00:1b.0
RP01	  S0	*disabled  pci:0000:00:1c.0
WLAN	  S0	*disabled  pci:0000:02:00.0
RP02	  S0	*disabled  pci:0000:00:1c.1
RMSC	  S0	*disabled  pci:0000:03:00.0
		*disabled  platform:rtsx_pci_sdmmc.0
		*disabled  platform:rtsx_pci_ms.0
RP03	  S3	*disabled  pci:0000:00:1c.2
NXUC	  S3	*disabled  pci:0000:04:00.0
RP04	  S3	*disabled  pci:0000:00:1c.3
RLAN	  S3	*enabled   pci:0000:05:00.0
PEG0	  S0	*disabled  pci:0000:00:01.0
PEGP	  S0	*enabled   pci:0000:01:00.0

 

[Ubuntu] 讓筆電闔上螢幕後不休眠

Ubuntu 18.04

在舊的 Sony VPCSB36FW 筆記型電腦安裝了 Ubuntu 18.04 當作桌機用,希望螢幕蓋上之後不要進入休眠,修改 /etc/systemd/logind.conf,加入 

HandleLidSwitch=ignore 

重開機或執行 

systemctl restart systemd-logind 

重新載入設定。

[Ubuntu] 自動掛載 NAS 網路磁碟機 (samba)

Ubuntu 18.04

首先建立一個要空資料夾,例如要掛載 NAS 上的 Download Station 資料夾,在 /mnt 下也建一個同名資料夾:

$ sudo mkdir "/mnt/Download Station"

如果只是臨時需要不要求每次開機都自動掛載的話,可以這樣下指令:

$ sudo mount -t cifs -o username="名字",password="密碼",gid="1000",uid="1000" "//NAS_IP/Download Station" "/mnt/Download Station"

其中 gid 與 uid 可使用 id your_username 取得,如果沒設 gid 與 uid 資料夾會變成 read-only。

繼續閱讀 “[Ubuntu] 自動掛載 NAS 網路磁碟機 (samba)”

[Ubuntu] 在 user mode 透過 sysfs 控制 gpio sample code

// gpio.h

#ifndef GPIO_H_
#define GPIO_H_

int gpio_is_requested(unsigned int gpio);
int gpio_request(unsigned int gpio);
int gpio_free(unsigned int gpio);
int gpio_direction_input(unsigned int gpio);
int gpio_direction_output(unsigned int gpio, int value);
int gpio_get_value(unsigned int gpio);
int gpio_set_value(unsigned int gpio, int value);

#endif

繼續閱讀 “[Ubuntu] 在 user mode 透過 sysfs 控制 gpio sample code”

[Ubuntu] 在 user mode 使用 sysfs 來控制 GPIO

Ubuntu 16.04

$ echo “4”>/sys/class/gpio/export 建立 gpio4 node
$ echo “in”>/sys/class/gpio/gpio4/direction 設 gpio4 為 input 
$ echo “out”>/sys/class/gpio/gpio4/direction 設 gpio4 為 output 
$ echo “1”>/sys/class/gpio/gpio4/value output High to gpio4
$ echo “0”>/sys/class/gpio/gpio4/value output Low to gpio4
$ echo “4”>/sys/class/gpio/unexport 取消 gpio4 node

繼續閱讀 “[Ubuntu] 在 user mode 使用 sysfs 來控制 GPIO”

[Ubuntu] Enable Ubuntu WOL function

Ubuntu 18.04

$ sudo apt install net-tools
$ sudo atp-get install ethtool

使用 ipconfig 查看 LAN 卡名稱:

$ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0
ether 02:42:c8:22:33:44 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

enp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.101 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::28db:9357:aa77:f13 prefixlen 64 scopeid 0x20<link>
ether 33:9c:52:07:66:88 txqueuelen 1000 (Ethernet)
RX packets 25517 bytes 2338698 (2.3 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 46529 bytes 14797516 (14.7 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 328 bytes 23053 (23.0 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 328 bytes 23053 (23.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

繼續閱讀 “[Ubuntu] Enable Ubuntu WOL function”

[TC++] 在 DOS 下 read/write 4G memory sample code

DOS 下使用 Flat mode 讀寫 4G memory 的 sample code。

所謂 flat mode 就是在主程式執行在 Real Mode 下,可是卻能讀寫 4G memory space的特殊模式,要進入 flat mode 也很簡單,首先先取得 gdt_table 的線性位址 (linear address),將 linear address 填入 gdtr offset 欄位,使用 lgdt 指令載入 gdt table,再來將 cr0 register bit0 設為1進入 protect mode,然後 selector (fs, fs, es, ss…) 選擇 gdt table 中的 data group,再清掉 cr0 register bit0 返回 real mode,以後要讀寫 4G memory space 時就直接使用 fs:[address] 來讀寫即可。

繼續閱讀 “[TC++] 在 DOS 下 read/write 4G memory sample code”

[Ubuntu] Debug card (80 port) driver sample code

要編譯要先安裝 build-essential 與 libelf-dev 套件, build-essential 包含了編譯 C / C++ 所需的套件,lebelf-dev 則包含編譯 driver (kernel module) 所需的程式。

$ sudo apt-get update
$ sudo apt-get install build-essential
$ sudo apt-get install libelf-dev
// debug_card.h
#ifndef _DEBUG_CARD_H_
#define MSG(format, arg...) printk(KERN_INFO "DEBUG CARD: " format "\n", ## arg)
#include <linux/ioctl.h>
#define DEV_MAJOR 121
#define DEV_NAME "debug"
#define DEV_IOCTLID 0xD0
#define IOCTL_WRITE _IOW(DEV_IOCTLID, 10, int)
#define IOCTL_RESET _IOW(DEV_IOCTLID, 0, int)
#endif

繼續閱讀 “[Ubuntu] Debug card (80 port) driver sample code”

[Ubuntu] GRUP 開機選單預設 Windows 開機

當 Windows 與 Ubuntu 安裝在一起,開機時會有 grub 開機選單可選擇使用 Windows 或 Ubuntu 開機,但 grub 預設為 Ubuntu 開機,改成預設 Windows 7 開機方法如下:

開啟終端機 (Ctrl-Alt-T),輸入 gedit /boot/grub/grub.cfg ,按 Ctl-F 搜尋 Windows 文字,找到 menuentry ‘Windows 7 (loader) (於 /dev/sda1)’ 這行 (引號中文字會因 Windows 版本與安裝位置有所不同),將引號及引號中文字複製下來。

繼續閱讀 “[Ubuntu] GRUP 開機選單預設 Windows 開機”