[![](https://gogs.es-lab.de/attachments/5a362329-e45e-40d0-a018-b7ddafd296f9)](https://www.hs-anhalt.de/startseite.html)
# <p>&#x1F5C3; Xcom-API</p>
[![]( https://img.shields.io/badge/version-v1.0-red.svg?style=plain )](https://gogs.es-lab.de/mueller_to/Xcom-API) [![]( https://img.shields.io/badge/python-3.4,_3.5,_3.6-green.svg?style=plain )](https://www.python.org/) [![]( https://img.shields.io/badge/license-GNU%20GPL%20v3-blue.svg?style=plain )](https://gogs.es-lab.de/mueller_to/Xcom-API/src/master/LICENSE) [![]( https://img.shields.io/badge/documentation-wiki-yellow.svg?style=plain)](https://gogs.es-lab.de/mueller_to/Xcom-API/wiki) [![]( https://img.shields.io/badge/download-zip-orange.svg?style=plain)](https://gogs.es-lab.de/mueller_to/Xcom-API/archive/master.zip)
## <p>&#x2139; Introduction</p>
This project is about an API (**A**pplication **P**rogramming **I**nterface) designed as a python-class, which is used to encode and decode byte-frames for communication between a Xtender-System and a PC, especially a Raspberry Pi with a Raspicomm extension module. The class also contains methods for error and frame-flag decoding and methods to get object or class informations.

>**Note:** The API and the Test-Program was created with Microsoft's integrated development environment (IDE) Visual Studio Code (VSC). This is an Open-Source IDE from Microsoft for many different programming-languages for Windows, Linux and Mac with an easy to use git integration. So you can easily add this project to VSC by cloning this Git-Repository. Of course you can open the python-files with other IDE's you prefer too.
>
>#### <p>&#x2601; Git-Repository-Link: https://gogs.es-lab.de/mueller_to/Xcom-API </p>

## <p>&#x1F5C2; Project-Folders</p> 
#### **Xcom-API**
This class is used to encode byte-frames, which are needed to communicate with Xtender-Moduls over the RS232-BUS with the Xcom-232i. After encoding the byte-frame, you can use the module "pyserial" to communicate with the Serial-BUS and to put the byte-frame into the write-method of "pyserial". You can also decode read-frames of the Serial-BUS with this class. 

The class contains methods to generate read- or write-frames, and methods to decode frames. There are pre-defined types, properties and formats for the most important parameter- and information-numbers. This reduces the effort for generating byte-frames, but there are extended methods to encode byte-frames with other parameter- and information-numbers too, that you can find in the documentation of the Xcom-232i. The class also contains methods for error and frame-flag decoding and methods to get object or class informations. 

More informations about the class and their methods you can find on the Wiki-Page.

#### **Xcom Test Program**
This program demonstrate the functionality of the Xcom_API-class. To use this program a Raspberry Pi with a Raspicomm extender module and a RS232-bridge called Xcom-232i is required. 

More information about the hardware-setup and the usage of the program you can find on the Wiki-Page.

#### **Xcom Test-Loop Program**
This program demonstrate the functionality of the Xcom_API-class. It sends permanently a request for a known object_id and display the answer from the Xtender-System. To use this program a Raspberry Pi with a Raspicomm extender module and a RS232-bridge called Xcom-232i is required.

More information about the hardware-setup and the usage of the program you can find on the Wiki-Page.

#### **Raspberry Pi Image**
Here you can find an image of the Raspberry Pi SD-Card, which i have used for testing. The COM-Port and GPIO setup in this image is already finished and ready to use.

On the Wiki Page you can find informations about: "How to copy the image to a SD-Card" and about "How to setup the COM-Port and GPIOs" on your own Raspberry-Distribution.

## <p>&#x1F4BB; Hardware-Configuration</p>  
#### **Hardware Information**

The following table shows the needed hardware components and their usage and give you links to the product information and documentation. These components are necessary if you want to use the Xcom-Test-Program and Xcom-Test-Loop-Program.

| Component | Function | Product Information | Documentation |
|:----|:----|:----:|:----:|
| Raspberry Pi 3 | single board computer, on which is running the program | [<p>&#x1F517;</p>](https://www.raspberrypi.org/products/raspberry-pi-3-model-b/) | [<p>&#x1F517;</p>](https://www.raspberrypi.org/documentation/) |
| RasPiComm | expansion board for the Raspberry Pi, which provides a RS232-Port over the GPIOs (UART) of the Raspberry Pi | Product not available anymore | Product not available anymore |
| Xcom-232i | CAN to RS232 Bridge, which is used to communicate with the Xtender-Modules | [<p>&#x1F517;</p>](https://www.studer-innotec.com/en/accessoires/xtender-series/communication-module-xcom-232i-770) | [<p>&#x1F517;</p>](https://www.studer-innotec.com/media/document/0/studer-manuel-xcom-232i-v1.3.0_en.pdf) [<p>&#x1F517;</p>](https://www.studer-innotec.com/media/document/0/technical-specification-xtender-serial-protocol-v1.6.24.zip) |
| RCC-02 | remote control and programming unit for displaying the status informations and to program parameters of the Xtender-Modules  | [<p>&#x1F517;</p>](https://www.studer-innotec.com/en/accessoires/xtender-series/rcc-02-remote-control-and-programming-centre-767) | [<p>&#x1F517;</p>](https://www.studer-innotec.com/media/document/0/manuel-rcc-v4.6.0_en.pdf) |
| Xtender-Series| is used as Battery charger and as DC to AC converter and to supply electrical power | [<p>&#x1F517;</p>](https://www.studer-innotec.com/en/products/xtender-series/) | [<p>&#x1F517;</p>](https://www.studer-innotec.com/media/document/0/manuel-xtender-v4.7.0_en-1.pdf) |

#### **Hardware Setup**

The picture below shows the connection of the Hardware components.

<a href="https://yuml.me/edit/cdb71477" target="_blank"><img src="https://gogs.es-lab.de/attachments/f121d125-dff9-4564-ae72-e85f82777cd9" /></a>

## <p>&#x2611; ToDo-List</p>  

The following checklist shows the actual state of this project.

* [x] create Git-Repository
* [x] upload project-files
* [x] finish "Xcom_API"
* [x] finish "Xcom_Test_Program"
* [x] finish "Xcom_Test_Loop_Program"
* [x] finish documentations/Wiki-Page

-----

**Hochschule Anhalt | Anhalt University of Applied Sciences | Department 6 EMW <br> Xcom-API**

<p>Tobias Müller, M. Eng.<br>
<a href="mailto:Tobias.Mueller@HS-Anhalt.de">&#x1F4E7; Tobias.Mueller@HS-Anhalt.de</a></p>

<p>&#x00A9; es-lab.de, 16.05.2018</p>