2018年12月21日 星期五
2018年11月20日 星期二
baudrate 算法
單位bit傳送時間 = 1/9600bps = 1.041×10-4(秒)
1Byte傳送時間 = 1.041×10-4×10bit = 1.041×10-3(秒)
(1Start Bit + 8Data Bits + 1Stop Bit = 10bits)
1Byte傳送時間 = 1.041×10-4×10bit = 1.041×10-3(秒)
(1Start Bit + 8Data Bits + 1Stop Bit = 10bits)
2018年10月11日 星期四
2018年10月6日 星期六
2018年6月4日 星期一
2018年6月3日 星期日
CURL
curl -C - -L -v -O --retry 999 -S
"http://www.archive.org/download/usgs_drg_nc_35077_b1/o35077b1.tif"
CURL *curl; CURLcode res; struct curl_slist *headers=NULL; // init to NULL is important headers = curl_slist_append(headers, "Accept: application/json"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://web.com/api/json/123");//cant get json file curl_easy_setopt(curl, CURLOPT_URL, "http://web.com/pages/123.html");//this returns entire webpage curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_RETURNTRANSFER, true); res = curl_easy_perform(curl); if(CURLE_OK == res) { char *ct; // ask for the content-type res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); if((CURLE_OK == res) && ct) printf("We received Content-Type: %s\n", ct); } } // always cleanup curl_easy_cleanup(curl);
"http://www.archive.org/download/usgs_drg_nc_35077_b1/o35077b1.tif"
CURL *curl; CURLcode res; struct curl_slist *headers=NULL; // init to NULL is important headers = curl_slist_append(headers, "Accept: application/json"); curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://web.com/api/json/123");//cant get json file curl_easy_setopt(curl, CURLOPT_URL, "http://web.com/pages/123.html");//this returns entire webpage curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_RETURNTRANSFER, true); res = curl_easy_perform(curl); if(CURLE_OK == res) { char *ct; // ask for the content-type res = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct); if((CURLE_OK == res) && ct) printf("We received Content-Type: %s\n", ct); } } // always cleanup curl_easy_cleanup(curl);
PID
https://www.cyberciti.biz/faq/linux-pidof-command-examples-find-pid-of-program/
#!/bin/bash # please ignore our pid and get all pids of lighttpd on server list=$(pidof -o %PPID lighttpd) # .. now do something on all pids stored in $list for p in $list do echo "Killing $p..." kill -TERM $p done |
2018年6月1日 星期五
standard output
「>/dev/null 2>&1」實際上在這裡會將左邊程式的執行結果丟給「/dev/null」,然後不管程式有什麼錯誤,也會一併丟給 null。熟悉 Unix 的人大概知道,「/dev/null」是 Unix 底下的垃圾筒+黑洞。它不帶任何意義,所有丟進去的東西都會被吃掉然後不見,反正你不想看到的東西丟給 null 就對了。而「>」的意思其實是,將「>」左邊輸出的東西重新導向到右邊去。但不止是這樣而已,系統將標準輸入輸出分成三個:標準輸入 (stdin)、標準輸出 (stdout)、以及標準錯誤輸出 (stderr),它們的 fd (file descriptor, 檔案描述子) 分別是 0、1、2。當「>」左邊未指定任何東西時,它會讀取左方程式的標準輸出 (也就是 fd=1) 重新導向給右邊的東西,但是你也可以指定要重新導向的 fd (也就是說「>abc.txt」會等於「1>abc.txt」)。所以可以想見 2>&1 的意思應該是把 fd=2,也就是標準錯誤輸出重新導向給 &1。而這邊的 &1 指的其實就是 fd=1。這邊似乎有點混淆視聽的感覺,為什麼「>」前面的 fd 不需要指定 &,後面的 fd 卻又要加 & 呢?我沒找到確切的原因,但是根據這篇討論,我認為有可能是因為「>」左邊只接受 fd,但右邊所接收的語法卻應該是檔案名稱。因此若用「2>1」其結果會變成「將標準錯誤輸出重新導向給檔案名稱為 "1" 的檔案」,所以我們需要用 & 來告訴系統後面的 "1" 指的是 fd。
接下來,有趣的東西來了。根據「man bash」裡 REDIRECTION 段落裡的說明,重新導向的順序是由左至右。也就是說「>/dev/null 2>&1」會先處理「>/dev/null」再處理「2>&1」。如果聽到這裡你覺得怪的話,再告訴你一件很幹的事。用「2>&1 >/dev/null」並不會將 stderr 導到 /dev/null。「man bash」裡的說明如下:
接下來,有趣的東西來了。根據「man bash」裡 REDIRECTION 段落裡的說明,重新導向的順序是由左至右。也就是說「>/dev/null 2>&1」會先處理「>/dev/null」再處理「2>&1」。如果聽到這裡你覺得怪的話,再告訴你一件很幹的事。用「2>&1 >/dev/null」並不會將 stderr 導到 /dev/null。「man bash」裡的說明如下:
Note that the order of redirections is significant. For example, the
command
ls > dirlist 2>&1
directs both standard output and standard error to the file dirlist,
while the command
ls 2>&1 > dirlist
directs only the standard output to file dirlist, because the standard
error was duplicated as standard output before the standard output was
redirected to dirlist.
2018年5月29日 星期二
使用zmodem 傳輸檔案
2018年5月27日 星期日
GPIO
https://blog.csdn.net/xnwyd/article/details/9042159
https://www.emcraft.com/som/vf6/controlling-gpio-from-linux
Now run the following shell commands to turn the LED on and off at a 1Hz frequency:
while echo hey; do echo 1 > gpio36/value; sleep 1; echo 0 > gpio36/value; sleep 1; done
https://www.emcraft.com/som/vf6/controlling-gpio-from-linux
Now run the following shell commands to turn the LED on and off at a 1Hz frequency:
while echo hey; do echo 1 > gpio36/value; sleep 1; echo 0 > gpio36/value; sleep 1; done
LTE_LEDon | MX6_PAD_GPIO_1__GPIO_1_1 | md 20E0210 |
LED1 | MX6_PAD_DISP0_DAT0__GPIO4_IO21 | md 20E00B0 |
LED2 | MX6_PAD_GPIO_2__GPIO1_IO02 | md 20E0224 |
LED3 | MX6_PAD_GPIO_4__GPIO1_IO04 | md 20E022C |
LED4 | MX6_PAD_GPIO_5__GPIO1_IO05 | md 20E0230 |
LED5 | MX6_PAD_EIM_D29__GPIO3_IO29 | md 20E0178 |
LED6 | MX6_PAD_EIM_D16__GPIO3_IO16 | md 20E0144 |
全亮: mw 20A8000 200000 mw 209C000 36 mw 20A4000 20010000 全熄: mw 20A8000 00 mw 209C000 00 mw 20A4000 00 |
2018年1月9日 星期二
Ethtool
+-------+ +-------+ +-------+ +-------+ +-------+ +-------+
| | | | | | | | | | | |
|Host |<-- br="" nbsp="">|Ctrl | | FIFOs | | MAC | MII | PHY | |Xformer| | RJ-45 |
|uC +-->| +-->| +------>| +--->| +-->| |
| | | | | | | | | | | |
+-------+ +-------+ +-------+ +-------+ +-------+ +-------+
https://serverfault.com/questions/566229/ethtool-says-that-eth0-uses-mii-but-twisted-pair-is-used-->
| | | | | | | | | | | |
|Host |<-- br="" nbsp="">|Ctrl | | FIFOs | | MAC | MII | PHY | |Xformer| | RJ-45 |
|uC +-->| +-->| +------>| +--->| +-->| |
| | | | | | | | | | | |
+-------+ +-------+ +-------+ +-------+ +-------+ +-------+
https://serverfault.com/questions/566229/ethtool-says-that-eth0-uses-mii-but-twisted-pair-is-used-->
訂閱:
文章 (Atom)