mirror of
https://github.com/seahu/rflink.git
synced 2025-12-10 07:57:23 +01:00
first commit
This commit is contained in:
146
RPi_rflink/Plug.cpp
Normal file
146
RPi_rflink/Plug.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
#include "Plug.h"
|
||||
|
||||
/**********************************************************************************************\
|
||||
* Load plugins
|
||||
* oreginal file name plugin.c, bat with this name g++ compiler have problem
|
||||
* therefore I create Plugin_001.cpp who contain #include to oreginal Plugin_001.c
|
||||
* and I create Plugin_001.h who contain all nessery headers file for compile and enable
|
||||
* use those modules in main program
|
||||
* Those files is generated by GNU make (only for enabled plagin in ../Config/Config_02.c)
|
||||
* PS: by GNU make is also generated files who is used here:
|
||||
* ./Plugins/Make_Generated_all_h.h
|
||||
* ./Plugins/Make_Generated_all_RX.h
|
||||
* ./Plugins/Make_Generated_all_TX.h
|
||||
\*********************************************************************************************/
|
||||
/**********************************************
|
||||
* example Plugin_001.cpp :
|
||||
*
|
||||
* #include "Plugin_001.h"
|
||||
* #ifdef PLUGIN_001
|
||||
* #include "../../Plugins/Plugin_001.c"
|
||||
* #endif
|
||||
**********************************************/
|
||||
/**********************************************
|
||||
* example Plugin_001.h :
|
||||
*
|
||||
* #ifndef _plugin_001_h
|
||||
* #define _plugin_001_h
|
||||
* #include "../../Config/Config_02.c"
|
||||
* #ifdef PLUGIN_001
|
||||
* #include "../Global.h"
|
||||
* //prototype functions
|
||||
* boolean Plugin_001(byte function, char *string);
|
||||
* #endif
|
||||
* #endif
|
||||
* *********************************************/
|
||||
|
||||
|
||||
// Van alle devices die worden mee gecompileerd, worden in een tabel de adressen opgeslagen zodat hier naar toe gesprongen kan worden
|
||||
boolean (*Plugin_ptr[PLUGIN_MAX])(byte, char*); // Receive plugins
|
||||
byte Plugin_id[PLUGIN_MAX];
|
||||
boolean (*PluginTX_ptr[PLUGIN_TX_MAX])(byte, char*); // Transmit plugins
|
||||
byte PluginTX_id[PLUGIN_TX_MAX];
|
||||
|
||||
|
||||
/*********************************************************************************************/
|
||||
void PluginInit(void)
|
||||
{
|
||||
byte x;
|
||||
|
||||
// Wis de pointertabel voor de plugins.
|
||||
for(x=0;x<PLUGIN_MAX;x++)
|
||||
{
|
||||
Plugin_ptr[x]=0;
|
||||
Plugin_id[x]=0;
|
||||
}
|
||||
|
||||
x=0;
|
||||
/*** examle entry of below includet file ***
|
||||
#ifdef PLUGIN_001
|
||||
Plugin_id[x]=1;Plugin_ptr[x++]=&Plugin_001;
|
||||
#endif
|
||||
********************************************/
|
||||
#include "./Plugins/Make_Generated_all_RX.h"
|
||||
// Initialiseer alle plugins door aanroep met verwerkingsparameter PLUGIN_INIT
|
||||
PluginInitCall(0,0);
|
||||
}
|
||||
/*********************************************************************************************/
|
||||
void PluginTXInit(void)
|
||||
{
|
||||
byte x;
|
||||
|
||||
// Wis de pointertabel voor de plugins.
|
||||
for(x=0;x<PLUGIN_TX_MAX;x++)
|
||||
{
|
||||
PluginTX_ptr[x]=0;
|
||||
PluginTX_id[x]=0;
|
||||
}
|
||||
|
||||
x=0;
|
||||
/*** examle entry of below includet file ***
|
||||
#ifdef PLUGIN_TX_001
|
||||
PluginTX_id[x]=1;PluginTX_ptr[x++]=&PluginTX_001;
|
||||
#endif
|
||||
********************************************/
|
||||
#include "./Plugins/Make_Generated_all_TX.h"
|
||||
// Initialiseer alle plugins door aanroep met verwerkingsparameter PLUGINTX_INIT
|
||||
PluginTXInitCall(0,0);
|
||||
}
|
||||
/*********************************************************************************************\
|
||||
* This function initializes the Receive plugin function table
|
||||
\*********************************************************************************************/
|
||||
byte PluginInitCall(byte Function, char *str) {
|
||||
int x;
|
||||
|
||||
for (x=0; x<PLUGIN_MAX; x++) {
|
||||
if (Plugin_id[x]!=0) {
|
||||
Plugin_ptr[x](Function,str);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*********************************************************************************************\
|
||||
* This function initializes the Transmit plugin function table
|
||||
\*********************************************************************************************/
|
||||
byte PluginTXInitCall(byte Function, char *str) {
|
||||
int x;
|
||||
|
||||
for (x=0; x<PLUGIN_TX_MAX; x++) {
|
||||
if (PluginTX_id[x]!=0) {
|
||||
PluginTX_ptr[x](Function,str);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/*********************************************************************************************\
|
||||
* With this function plugins are called that have Receive functionality.
|
||||
\*********************************************************************************************/
|
||||
byte PluginRXCall(byte Function, char *str) {
|
||||
int x;
|
||||
|
||||
for (x=0; x<PLUGIN_MAX; x++) {
|
||||
if (Plugin_id[x]!=0) {
|
||||
SignalHash=x; // store plugin number
|
||||
if (Plugin_ptr[x](Function,str)) {
|
||||
SignalHashPrevious=SignalHash; // store previous plugin number after success
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/*********************************************************************************************\
|
||||
* With this function plugins are called that have Transmit functionality.
|
||||
\*********************************************************************************************/
|
||||
byte PluginTXCall(byte Function, char *str) {
|
||||
int x;
|
||||
|
||||
for (x=0; x<PLUGIN_TX_MAX; x++) {
|
||||
if (PluginTX_id[x]!=0) {
|
||||
if (PluginTX_ptr[x](Function,str)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user