飛行派工作日誌《一》

放下不確定之感覺,理性的審視疑慮,一個貌似瘋狂的點子,或有一定合理的內核。若是將可能的『改善』,與不可能的『排除』,也許終會得到可行方案哩。

因此作者先藉由維基百科詞條,了解

乙太網供電

乙太網供電Power over Ethernet,簡稱PoE)也稱PoE供電,是一種可以在乙太網路中透過雙絞線來傳輸電力與資料到裝置上的技術。

介紹

透過這項技術可使包括網路電話無線基地台網路攝影機集線器電腦等裝置都能採用PoE技術供電,由於能藉由乙太網路獲得供電的電子裝置無需額外的電源插座就可使用,所以同時能省去配置電源線的時間與金錢,使整個裝置系統的成本相對降低。而目前全球均普遍採用RJ-45網路插座,因此各種PoE裝置都具備相容性。這項技術常常被跟同樣也是在同一條電纜上接收電源與資料(雖然是類比資料)的傳統電話網路(POTS)來對照。PoE不需要更改乙太網路的纜線架構即可運作,所以採用PoE系統不但節省成本易於布線安裝還具備了遠程通電、斷電的能力。

PoE又分為供電端(Power Sourcing Equipment,簡稱PSE)和受電端(Powered Device,簡稱PD)。還有AT和AF的差別。

原始的IEEE 802.3af-2003標準提供了一台機器15.4W DC功率的保證(最小值可為44V DC與350mA)。但其中穩定功率只有12.95W,這是由於雙絞線中存在有電力損耗。

經過改良的IEEE 802.3at-2009 PoE標準,也就是PoE+,可以為裝置提供高達25.5W的電功率。此2009年 的標準不允許裝置將4對線纜全部用作供電。一些廠商已經宣布的產品指標中包含了聲稱相容802.3at的標準之產品。它們(被聲稱)能夠實現51W的高功 率。這些產品通過一根主供電線纜配合全部四組其他從線纜進行供電。這些線纜均為5類雙絞線(CAT-5

PoE也有競爭者,即USB(Universal Serial Bus)技術,同樣同時提供資料和電能。但這個標準是為小距離應用(上限為5米,即16英尺)而設計的,獨立供電功率低於2.5W。它比PoE更加廉價,也能同小功率外圍裝置完美配合,例如你的PC滑鼠、耳機和集線器。然而,一些外圍裝置如揚聲器、掃描儀和印表機需要的電能無法籍由USB提供。火線,即FirewireIEEE1394)很像USB,卻可以提供明顯多於其的電量。(火線提供45W的電功率)然而火線的距離限制為4.5m,甚至近於USB。

有許多不同的名詞都是意指這個功能。Power over Ethernet (PoE)、Power over LAN (PoL), Power on LAN (PoL),以及Inline Power,都是指由乙太網路孔供電給各種裝置的技術。

PoE有許多實做的方式,包括ad-hoc的方法,但是建議使用IEEE的標準來實做由網路線供電的技術。

 

知道標準供應功率以及線材規格︰

Terminology

Power sourcing equipment

Power sourcing equipment (PSE) is a device such as a network Switch that provides (or sources) power on the Ethernet cable. The maximum allowed continuous output power per cable in IEEE 802.3af is 15.40 W. A later specification, IEEE 802.3at, offers 25.50 W.

When the device is a switch, it is commonly called an endspan (although IEEE 802.3af refers to it as endpoint). Otherwise, if it’s an intermediary device between a non PoE capable switch and a PoE device, it’s called a midspan. An external PoE injector is a midspan device.[16]

Powered device

A powered device (PD) is a device powered by a PSE and thus consumes energy. Examples include wireless access points, IP Phones, and IP Cameras.

Many powered devices have an auxiliary power connector for an optional, external, power supply. Depending on the PD design, some, none, or all power can be supplied from the auxiliary port,[17][18] with the auxiliary port sometimes acting as backup power in case of PoE supplied power failure.

Standard implementation

Standards-based Power over Ethernet is implemented following the specifications in IEEE 802.3af-2003 (which was later incorporated as clause 33 into IEEE 802.3-2005) or the 2009 update, IEEE 802.3at. A phantom power technique is used to allow the powered pairs to also carry data. This permits its use not only with 10BASE-T and 100BASE-TX, which use only two of the four pairs in the cable, but also with 1000BASE-T (gigabit Ethernet), which uses all four pairs for data transmission. This is possible because all versions of Ethernet over twisted pair cable specify differential data transmission over each pair with transformer coupling; the DC supply and load connections can be made to the transformer center-taps at each end. Each pair thus operates in common mode as one side of the DC supply, so two pairs are required to complete the circuit. The polarity of the DC supply may be inverted by crossover cables; the powered device must operate with either pair: spare pairs 4–5 and 7–8 or data pairs 1–2 and 3–6. Polarity is required on data pairs, and ambiguously implemented for spare pairs, with the use of a diode bridge.

PoE vs PoE+ parameters
Property 802.3af (802.3at Type 1) “PoE” 802.3at Type 2 “PoE+”
Power available at PD[note 1] 12.95 W 25.50 W
Maximum power delivered by PSE 15.40 W 30.0 W
Voltage range (at PSE) 44.0–57.0 V[21] 50.0–57.0 V[21]
Voltage range (at PD) 37.0–57.0 V[22] 42.5–57.0 V[22]
Maximum current 350 mA[23] 600 mA[23] per mode
Maximum cable resistance 20 Ω[24] (Category 3) 12.5 Ω[24] (Category 5)
Power management Three power class levels negotiated at initial connection Four power class levels negotiated at initial connection or 0.1 W steps negotiated continuously
Derating of maximum cable ambient operating temperature None 5 °C (9 °F) with one mode (two pairs) active
Supported cabling Category 3 and Category 5[1] Category 5[1][note 2]
Supported modes Mode A (endspan), Mode B (midspan) Mode A, Mode B

Notes:

  1. Most switched power supplies within the powered device will lose another 10 to 25% of the available power.
  2. More stringent cable specification allows assumption of more current carrying capacity and lower resistance (20.0 Ω for Category 3 versus 12.5 Ω for Category 5).

 

建立 PSE 、 PD 環境

basic-poe-solution-diagram

 

,待測得數據後,再和朋友較真也。

 

 

 

 

 

 

 

 

 

飛行派工作日誌《初》

原本以為朋友突發奇想,不過當它是個玩笑!結果接到了 e-mail ,上有一張 BOM 表。一旦事已成真,驚訝成了現實?還得細心思量『第一刀』的哩。

 

mjh3

樹莓派 3B x1

WiFi AP dongle x1

66 channel GPS x1

RaspiCAM x1

NoIR RaspiCAM x1

Case w/Camera mount x1

8mm NeoPixel LED Pack x1

PoE injector x1

PoE Splitter x1

 

mjh1 飛行

Kite [TBD] x1

PoE CAT5 Cable [at least 300 ft] x1

Battery Power Supply w/AC output x1

AP Router x1

Base Pi x1

 

儼然朋友自比『東道主』,我作『西席』乎!不知那 LED 卻是要來何用耶?

 

 

 

 

 

 

 

 

 

飛行派 FlyingPi ??!!

老少年‧唐伯虎

人為多愁少年老,
花為無愁老少年。
年老少年都不管,
且將詩酒醉花前。

 

朋友說︰

受到 Flying Python 之啟發

python-frying

http://imgs.xkcd.com/comics/python.png

 

將製造飛行派也。作者︰你是說 drone ,無人駕駛飛機嗎?朋友︰不是。是將樹莓派裝在風箏上,用乙太網為線供電,放風箏。這可實驗許多事情, GPS 、 WiFi 、 Camera 、 …… 種種性能。作者︰可行嗎?也許充氦氣球比較安全。

bep-jones-franklin_and_electricity

Franklin and Electricity vignette engraved by the BEP (c. 1860).

 

朋友︰又不是要取閃電。這是晴天放的風箏。路是走出來的!人不輕狂罔少年。何況祇要你作派,至於飛行實證真理之事,就看我了 。作者︰///★

不知當多愁亦無愁矣☆

 

 

 

 

 

 

 

 

樹莓派 HATs ︰ I2C 拾遺《四》

若是對 I2C 與 python-smbus 不太熟悉的讀者,請先參考

W!o+ 的《小伶鼬工坊演義》︰ 從下而上‧由上往下

W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計《解讀》

文本相關對落以及鍊結。

此處以派生三 python3 為例,按造 24C32 Data Sheet 所言,

cat24c32-w1

cat24c32-w2

cat24c32-r1

cat24c32-2

 

建制隨選地址 Random Address 之位元組讀寫 Byte I/O 程式︰

pi@raspberrypi:~ sudo modprobe i2c_dev pi@raspberrypi:~ sudo dtoverlay i2c-gpio i2c_gpio_sda=0 i2c_gpio_scl=1
pi@raspberrypi:~ i2cdetect -y 3      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 00:          -- -- -- -- -- -- -- -- -- -- -- -- --  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  50: 50 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  70: -- -- -- -- -- -- -- --                          </pre>   <pre class="lang:python decode:true ">pi@raspberrypi:~ python3
Python 3.4.2 (default, Oct 19 2014, 13:31:11) 
[GCC 4.9.1] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from smbus import SMBus
>>> smb=SMBus(3)
>>> EEPROM = 0x50
>>> def 設置目前位置(地址):
...     高位元組 = 地址 // 256
...     低位元組 = 地址 % 256
...     smb.write_i2c_block_data(EEPROM, 高位元組, [低位元組])
... 
>>> def 讀一位元組(地址):
...     設置目前位置(地址)
...     return smb.read_byte(EEPROM)
... 
>>> def 寫一位元組(地址, 資料):
...     高位元組 = 地址 // 256
...     低位元組 = 地址 % 256
...     資料.insert(0,低位元組)
...     smb.write_i2c_block_data(EEPROM, 高位元組, 資料)
...     完成 = 0
...     while not 完成:
...         try:
...             smb.read_byte(EEPROM)
...             完成 = 1
...         except IOError:
...             完成 = 0
... 
>>> 讀一位元組(0)
82
>>> 寫一位元組(0, [80])
>>> 讀一位元組(0)
80
>>> 寫一位元組(0, [82])
>>> 讀一位元組(0)
82
>>> 

 

相信讀者自能掌握其餘的了。

 

 

 

 

 

 

 

 

樹莓派 HATs ︰ I2C 拾遺《三》

人們通常希望『好人作到底,送佛送到西』,只不過有時候

MAMELogoTM
Multiple Arcade Machine Emulator

220px-Mspacman_and_galaga_act_like_israel_and_palestine
街頭遊戲機

一九九七年,義大利程式設計師 Nicola Salmoria 開啟了街頭電玩的軟體模擬器發展,當年一月二十九日發表的 DOS 平台的 Multi-Pac v0.8 版, 就是現今著名 MAME 的前身。據知 MAME 的目標在於盡可能的忠實而且精確的模擬各種街機遊戲,它的宗旨為著保存遊戲的歷史,進而避免古老的遊戲恐將遺失或被忘卻。計畫全稱是個縮首字,由 Multiple Arcade Machine Emulator 而得名。

就像 WiKi  上所講的, Philosophy and accuracy 】︰

The stated aim of the project is to document hardware, and so MAME takes a somewhat purist 【純正化】view of emulation, prohibiting 【禁止】programming hacks that might make a game run improperly or run faster at the expense of emulation accuracy. Components such as CPUs are emulated at a low level (meaning individual instructions are emulated) whenever possible, and high-level emulation (HLE) is only used when a chip is completely undocumented and cannot be reverse-engineered 【逆向工程】 in detail. Signal level emulation is used to emulate audio circuitry that consists of analog components.

這大概不只是『 bit by bit 』的『拷貝』而已,或許真的是『克隆』的吧!然而至今『硬體文件』依然付之闕如,這事二零零八年計畫督導者是這麼說的︰

We want to document the hardware. Now a lot of people will say; “Where’s your document? You just write a bunch of source code.” And yes, that’s true. One thing I’ve learned is that keeping documentation synced with source code is nearly impossible. The best proof that your documentation is right is “does this code work“.

Aaron Giles, California Extreme 2008

果真是『大哉辯』的啊!『能用』比之於『能文』到底哪個重要的呢?希望不會有一天又要『再詮釋』一次的吧!!??這就宛如在《 Raspberryλ◇樹莓λ 》一文中的『 cgroup 』是什麼的呢?就像《 kernel lacks cgroups or memory controller not avaiable, not … 》裡所議論的一樣,即使最近的文件也就如《 Web browser beta 》所講的『差不多』罷了,也許是不容易『說清楚』的吧。由於 MAME 的著作授權有別於 GPLBSD 的原故,在此也只能說樹莓派上的安裝辦法,以饗讀者的了。

─── 摘自《音樂播放器之 CD 轉成 mp3 之《補充》 MAME?!

 

『原始碼』 source code 是唯一最詳實文件的哩??那麼就讀碼嘗試的吧!!

eeprog.c

/***************************************************************************
copyright : (C) by 2003-2004 Stefano Barbato
email : stefano@codesink.org

Copyright (C) 2011 by Kris Rusocki <kszysiu@gmail.com>
– usage/strings cleanup
– misc cleanup: use “static” keyword where appropriate
– misc cleanup: have confirm_action() return void
– support custom input and output files
– support user-defined write cycle time
– ensure that stdin is a terminal when operating w/o -f
– do not allow reading data from a terminal w/o -f
– perform complete input validation before taking action
– use dedicated exit code when opening I2C device fails

Id: eeprog.c,v 1.28 2004/02/29 11:06:41 tat Exp
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

 

#define die_if3(a, msg, code) do { do_die_if( a , msg, __LINE__, code); } while(0)
#define die_if(a, msg) die_if3(a, msg, 1)
static void do_die_if(int b, char* msg, int line, int exitcode)
{
if(!b)
return;
fprintf(stderr, “Error at line %d: %s\n”, line, msg);
//fprintf(stderr, ” sysmsg: %s\n”, strerror(errno));
exit(exitcode);
}

 

static int read_from_eeprom(struct eeprom *e, FILE *fp, int addr, int size, int hex)
{
int ch, i;
for(i = 0; i < size; ++i, ++addr)
{
die_if((ch = eeprom_read_byte(e, addr)) < 0, “read error”);
if(hex)
{
if( (i % 16) == 0 )
fprintf(fp, “\n %.4x| “, addr);
else if( (i % 8) == 0 )
fprintf(fp, ” “);
fprintf(fp, “%.2x “, ch);
} else
putc(ch, fp);
}
if(hex)
fprintf(fp, “\n\n”);
fflush(fp);
return 0;
}

static int write_to_eeprom(struct eeprom *e, FILE *fp, int addr)
{
int c;
while((c = fgetc(fp)) != EOF)
{
print_info(“.”);
fflush(stdout);
die_if(eeprom_write_byte(e, addr++, c), “write error”);
}
print_info(“\n\n”);
return 0;

 

pi@raspberrypi:~/hats/eepromutils/eeprog/eeprog-0.7.6-tear12 ./eeprog -h eeprog 0.7.6-tear12, a 24Cxx EEPROM reader/writer Copyright (c) 2003-2004 by Stefano Barbato - All rights reserved. Copyright (c) 2011 by Kris Rusocki - All rights reserved. Usage: 	eeprog [-fqxd] [-16|-8] -r addr[:count] [-o file] /dev/i2c-N  i2c-address 	eeprog [-fqd] [-16|-8] -w addr [-i file] [-t tWC] /dev/i2c-N  i2c-address 	eeprog -h    Address modes:  	-8		Use 8bit address mode for 24c0x...24C16 [default] 	-16		Use 16bit address mode for 24c32...24C256   Actions:  	-r addr[:count]	Read [count] (1 if omitted) bytes from [addr] 			and print them to the standard output (or file 			specified by -o) 	-w addr		Write stdin (or file specified by -i) starting 			at address [addr] of the EEPROM 	-h		Print this help   Options:  	-i file		Read input from [file] (for use with -w) 	-o file		Write output to [file] (for use with -r) 	-x		Set hex output mode 	-d		Dummy mode, display what *would* have been done 	-f		Disable warnings and don't ask confirmation 	-q		Quiet mode 	-t tWC		Define chip's write cycle time to [tWC] miliseconds  The following environment variables could be set instead of the command line arguments: 	EEPROG_DEV		device name(/dev/i2c-N) 	EEPROG_I2C_ADDR		i2c-address  	Examples 	1- read 64 bytes from the EEPROM at address 0x54 on bus 0 starting 	   at address 123 (decimal) 		eeprog /dev/i2c-0 0x54 -r 123:64 	2- prints the hex codes of the first 32 bytes read from bus 1  	   at address 0x22 		eeprog /dev/i2c-1 0x51 -x -r 0x22:0x20 	3- write the current timestamp at address 0x200 of the EEPROM on  	   bus 0 at address 0x33  		date | eeprog /dev/i2c-0 0x33 -w 0x200 -f  [line 250] pi@raspberrypi:~/hats/eepromutils/eeprog/eeprog-0.7.6-tear12 

 

pi@raspberrypi:~/hats/eepromutils/eeprog/eeprog-0.7.6-tear12 $ sudo modprobe i2c_dev

pi@raspberrypi:~/hats/eepromutils/eeprog/eeprog-0.7.6-tear12 $ sudo dtoverlay i2c-gpio i2c_gpio_sda=0 i2c_gpio_scl=1

pi@raspberrypi:~/hats/eepromutils/eeprog/eeprog-0.7.6-tear12 $ ./eeprog -f -o test.bin -16 -r 0:4096 /dev/i2c-3 0x50
eeprog 0.7.6-tear12, a 24Cxx EEPROM reader/writer
Copyright (c) 2003-2004 by Stefano Barbato – All rights reserved.
Copyright (c) 2011 by Kris Rusocki – All rights reserved.
Bus: /dev/i2c-3, Address: 0x50, Mode: 16bit
Operation: read 4096 bytes from offset 0, Output file: test.bin
Reading 4096 bytes from 0x0

pi@raspberrypi:~/hats/eepromutils/eeprog/eeprog-0.7.6-tear12 $ hexedit test.bin

test

 

pi@raspberrypi:~/hats/eepromutils/eeprog/eeprog-0.7.6-tear12 $ ./eeprog -f -i test.bin -16 -w 0 -t 5 /dev/i2c-3 0x50
eeprog 0.7.6-tear12, a 24Cxx EEPROM reader/writer
Copyright (c) 2003-2004 by Stefano Barbato – All rights reserved.
Copyright (c) 2011 by Kris Rusocki – All rights reserved.
Bus: /dev/i2c-3, Address: 0x50, Mode: 16bit
Operation: write at offset 0, Input file: test.bin
Write cycle time: 5 milliseconds
Writing test.bin starting at address 0x0
…………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………………

 

pi@raspberrypi:~/hats/eepromutils $ sudo ./eepflash.sh -r -f=test-ref.eep -t=24c32
This will attempt to talk to an eeprom at i2c address 0x50. Make sure there is an eeprom at this address.
This script comes with ABSOLUTELY no warranty. Continue only if you know what you are doing.
Do you wish to continue? (yes/no): yes
Reading…
8+0 records in
8+0 records out
4096 bytes (4.1 kB) copied, 0.244026 s, 16.8 kB/s
Done.
pi@raspberrypi:~/hats/eepromutils $ hexedit test-ref.eep

test-ref