sketchbook
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions | Variables
DeviceGeneric.cpp File Reference

Example-Code for a generic Server (e.g. Sensor, Display) More...

#include <stdio.h>
#include <inttypes.h>
#include <stdlib.h>
#include <string.h>
#include <wiringPi.h>
#include <PJON.h>

Macros

#define RPI   true
 
#define TS_RESPONSE_TIME_OUT   35000
 
#define PJON_INCLUDE_TS   true
 
#define BLOCK_SIZE   256
 

Functions

PJON< ThroughSerial > bus (45)
 
void loop ()
 
int main (int argc, char *argv[])
 

Variables

char buffer [BLOCK_SIZE]
 

Detailed Description

Example-Code for a generic Server (e.g. Sensor, Display)

Author
drtrigon
Date
2018-07-06
Version
1.0
  • first version derived from PJON 11.0 examples examples/LINUX/Local/EthernetTCP/RemoteWorker/Transmitter/Transmitter.cpp
TODO: THIS CODE NEEDS AN UPDATE - ADOPT IT TO THE LATEST LUDP CODE (LINUX/Local/LocalUDP/...) Also considering LUDP_RESPONSE_TIMEOUT versus TS_RESPONSE_TIME_OUT.

It sends REQUESTS to device id 44 which is on a SWBB bus connected to the Tunnel, and receives replies back. Device 44 is the example: OWPJON/ARDUINO/Local/SoftwareBitBang/DeviceGeneric/

This demonstrates the concept with a process on a PC or a RPI transparently being part of a SWBB bus via a Tunnel. The Tunnel/Surrogate will "phone home" to the RemoteWorker to create a permanent link.

See Also
https://github.com/gioblu/PJON/blob/master/examples/LINUX/Local/EthernetTCP/RemoteWorker/Transmitter/Transmitter.cpp
* OneWire PJON Generic "OWPG" scheme:
*   Server e.g. linux machine or raspi
*      OWPJON/LINUX/Local/LocalUDP/RemoteWorker/DeviceGeneric/
*      OWPJON/LINUX/Local/ThroughSerial/RemoteWorker/DeviceGeneric/ (this sketch)
*   Tunnel(er) similar to 1wire master (similar cause we are on a multi-master bus) e.g. AVR
*      OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch/
*      OWPJON/ARDUINO/Local/SoftwareBitBang/Tunneler/BlinkingSwitch_SWBB-TS/
*      OWPJON/ARDUINO/Local/ThroughSerial/SoftwareBitBangSurrogate/Surrogate/ (obsolete)
*   Devices e.g. AVR
*      OWPJON/ARDUINO/Local/SoftwareBitBang/DeviceGeneric/
*      OWPJON/ARDUINO/Local/SoftwareBitBang/OWP_DG_LCD_Sensors/
*      ...
*
* Compatible with: ubuntu 14.04, raspi
*
* Compile wiringPi using:
* $ git clone git://git.drogon.net/wiringPi
* $ cd wiringPi
* $ ./build
*
* Example sending READ_INFO 0x01 to device id 44:
* $ printf "\x01" | sudo ./owpshell /dev/ttyACM0 9600 44
* owp:dg:v1
* $ printf "\x11" | sudo ./owpshell /dev/ttyACM0 9600 44 | unpack.py f
* 4.771999835968018,
* $ printf "\x12" | sudo ./owpshell /dev/ttyACM0 9600 44 | unpack.py f
* 28.02459144592285,
* More info can be found in @ref OWPJON/README.md.
*
* Thanks to:
* gioblu - PJON 11.0 and support
*          @see https://www.pjon.org/
*          @see https://github.com/gioblu/PJON
* fredilarsen - support
* 

Macro Definition Documentation

#define BLOCK_SIZE   256
#define PJON_INCLUDE_TS   true
#define RPI   true
#define TS_RESPONSE_TIME_OUT   35000

Function Documentation

PJON<ThroughSerial> bus ( 45  )
void loop ( void  )

OneWirePJON device status update function.

Returns
(void)
int main ( int  argc,
char *  argv[] 
)

Variable Documentation

char buffer[BLOCK_SIZE]