ZBus: Unterschied zwischen den Versionen

Aus Ethersex_Wiki
Wechseln zu: Navigation, Suche
(Weiterleitung nach Kategorie:ZBus erstellt)
 
Zeile 1: Zeile 1:
ZBus ist ein auf [[wikipedia:RS485|RS485]] basierendes Zweidraht-Bussystem, auf welchem Pakete variabler Länge übermittelt werden können. 
+
#REDIRECT[[:Kategorie:ZBus]]
Es wurde primär für die Datenübertragung zwischen Mikrocontrollern konzipiert, zum Beispiel zur Kommunikation von ATmega8 und ATmega644.  Ethersex verwendet ZBus zur Übermittlung von IP-Paketen von einem Controller, der als Bridge fungiert, hin zu einzelnen kleineren ZBus-Geräten, die beispielsweise auf ATmega8 basieren.
 
 
 
==  ZBus Interface ==
 
 
 
Ethersex can also be compiled for smaller ATmegas, like the ATmega8. In this
 
case you normally don't attach a [[ENC28J60]] to the
 
little IC. Instead you can add a RS485
 
driver IC. Over this serial line all the communication will be done. In the
 
small ATmega8 a whole IPv4 ( or IPv6 ) stack is installed and it processes the
 
data, which comes over the serial line. The stack will be able to process ICMP
 
and UDP, but TCP is not possible with this amount of RAM.
 
 
 
The interface between the ZBus "net" and the normal LAN is a biggger ATmega
 
(e.g. ATmega644) with both, a ethernet driver and a RS485 driver. For more
 
informations about the zbus bridges look see [[Network Briges]]. It can also be a normal computer with a serial interface and [[#ZBus Serial Host]] running on it.
 
 
 
== ZBus Protocol ==
 
 
 
ZBus is a protocol to transfer packets over an serial line, where only one
 
byte can be sent at once, e.g. RS485. The problem with such a serial line is,
 
that every byte is independend from another byte. So you have to define a
 
format for a packets, in which you can chain many bytes together, in
 
order send more information than just one byte. ZBus is such an format.
 
 
 
ZBus is a little bit related to [[I2C]]: There is an start condtition at the
 
beginning of a packet and a stop conditon at the end. Between start and
 
stop condtiontion is no field that represents the length of the packet.
 
 
 
The start condtiotion is an '\' (0x5C) followed by an '0' (0x30).
 
Corresponding to that is the stop condition an '\' (0x5C) followed by an
 
'1' (0x31). But we also have to escape all '\' (0x5C) inside the packet,
 
so that an start condtiotion can't be happen at random. ZBus does this in
 
the normal Unix way by replacing every '\' with an '\\'
 
 
 
A packet can for example look like this:
 
 
 
\0get information about \\0 and \\1 in zbus\1
 
 
 
The plain message whoul be:
 
 
 
get information about \0 and \1 in zbus
 
 
 
== Hardware ==
 
 
 
The only thing you need to extend an ATmega* with ZBus is a RS485 IC (e.g. MAX485). A example how the IC is attached to the single ATmegas is at [[Media:Zbus.pdf]]
 
 
 
 
 
== ZBus Serial Host ==
 
Because ZBus is based on the Usart feature, with have almost all ATmegas, we can simply attach an ZBus network interface to our computer.
 
The serial interface (aka COM-Port, aka R232) is only an normal usart with signal level converter ( -3V - +15V ). In order to make a RS485 interface, which is needed for ZBus, you will have to attach a MAX232 ( or similar ), to convert the RS232 signal back to an Usart TTL signal, and a RS485 interface chip to create the differential signal.
 
 
 
Some embedded device have some usarts on board, which are not soldered to a signal converter, so they provide the Usart TTL signal directly. You must only attach the RS485 chip and compile the driver for the architecture. The Linksys WRT54G is such an embedded device with an unsoldered Usart on board.
 
 
 
On the software side, i decided to write an userland driver with tun devices instead of writing a kernel module, because it is much more simpler to code and to debug. The programm provides an usual network interface, like your normal ethernet card, and can also be used like it (e.g. routing, different IP addresses and so on ). So you are very fexible with it. You can find the driver daemon at [http://git.brokenpipe.de/cgi-bin/gitweb.cgi?p=ethersex;a=tree;f=contrib/zbus-serial-host;hb=master contrib/zbus-serial-host]
 
 
 
<pre>
 
zbus0    Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
 
          inet addr:192.168.9.1  P-t-P:192.168.9.1  Mask:255.255.255.0
 
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:174  Metric:1
 
          RX packets:16418 errors:0 dropped:0 overruns:0 frame:0
 
          TX packets:16423 errors:0 dropped:0 overruns:0 carrier:0
 
          collisions:0 txqueuelen:500
 
          RX bytes:1381934 (1.3 MiB)  TX bytes:1379532 (1.3 MiB)
 
</pre>
 
 
 
An open source rs232 to rs485 converter you can be found at [[RS485 Converter]].
 
 
 
== ZBus Bootloader ==
 
 
 
We have also written a [http://git.brokenpipe.de/cgi-bin/gitweb.cgi?p=bricolage/zbusloader;a=summary small bootloader] which is able to flash your devices (at the moment only ATmega8 is supported) over the ZBus line. It fits into
 
512 bytes of flash. You have to enable zbus_raw on your ethernet-zbus bridge,
 
because the zbusloader doesn't use IP packets to communicate with the
 
bootloader, but raw ZBus packets. You can find more informations in the zbusloader [http://git.brokenpipe.de/cgi-bin/gitweb.cgi?p=bricolage/zbusloader;a=blob;f=README;hb=master README]
 
 
 
=== Code ===
 
git clone http://brokenpipe.de/gitroot/bricolage/zbusloader
 
 
 
 
 
 
 
[[Category:ethersex]]
 

Aktuelle Version vom 1. Mai 2009, 17:02 Uhr

Weiterleitung nach: