2002-10-06 10:25:42 +02:00
|
|
|
/*
|
|
|
|
* diseqc.h: DiSEqC handling
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2017-01-09 15:21:13 +01:00
|
|
|
* $Id: diseqc.h 4.1 2017/01/09 15:11:19 kls Exp $
|
2002-10-06 10:25:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DISEQC_H
|
|
|
|
#define __DISEQC_H
|
|
|
|
|
|
|
|
#include "config.h"
|
2013-08-21 11:02:52 +02:00
|
|
|
#include "positioner.h"
|
2011-09-11 14:09:03 +02:00
|
|
|
#include "thread.h"
|
|
|
|
|
2013-08-21 11:02:52 +02:00
|
|
|
class cDiseqcPositioner : public cPositioner {
|
|
|
|
private:
|
|
|
|
void SendDiseqc(uint8_t *Codes, int NumCodes);
|
|
|
|
public:
|
|
|
|
cDiseqcPositioner(void);
|
|
|
|
virtual void Drive(ePositionerDirection Direction);
|
|
|
|
virtual void Step(ePositionerDirection Direction, uint Steps = 1);
|
|
|
|
virtual void Halt(void);
|
|
|
|
virtual void SetLimit(ePositionerDirection Direction);
|
|
|
|
virtual void DisableLimits(void);
|
|
|
|
virtual void EnableLimits(void);
|
|
|
|
virtual void StorePosition(uint Number);
|
|
|
|
virtual void RecalcPositions(uint Number);
|
|
|
|
virtual void GotoPosition(uint Number, int Longitude);
|
|
|
|
virtual void GotoAngle(int Longitude);
|
|
|
|
};
|
|
|
|
|
2011-09-11 14:09:03 +02:00
|
|
|
class cScr : public cListObject {
|
|
|
|
private:
|
2011-09-17 14:13:31 +02:00
|
|
|
int devices;
|
2011-09-11 14:09:03 +02:00
|
|
|
int channel;
|
|
|
|
uint userBand;
|
|
|
|
int pin;
|
|
|
|
bool used;
|
|
|
|
public:
|
|
|
|
cScr(void);
|
|
|
|
bool Parse(const char *s);
|
2011-09-17 14:13:31 +02:00
|
|
|
int Devices(void) const { return devices; }
|
2011-09-11 14:09:03 +02:00
|
|
|
int Channel(void) const { return channel; }
|
|
|
|
uint UserBand(void) const { return userBand; }
|
|
|
|
int Pin(void) const { return pin; }
|
|
|
|
bool Used(void) const { return used; }
|
|
|
|
void SetUsed(bool Used) { used = Used; }
|
|
|
|
};
|
|
|
|
|
|
|
|
class cScrs : public cConfig<cScr> {
|
|
|
|
private:
|
|
|
|
cMutex mutex;
|
|
|
|
public:
|
2013-08-21 11:02:52 +02:00
|
|
|
bool Load(const char *FileName, bool AllowComments = false, bool MustExist = false);
|
2011-09-17 14:13:31 +02:00
|
|
|
cScr *GetUnused(int Device);
|
2011-09-11 14:09:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern cScrs Scrs;
|
2002-10-06 10:25:42 +02:00
|
|
|
|
|
|
|
class cDiseqc : public cListObject {
|
|
|
|
public:
|
|
|
|
enum eDiseqcActions {
|
|
|
|
daNone,
|
|
|
|
daToneOff,
|
|
|
|
daToneOn,
|
|
|
|
daVoltage13,
|
|
|
|
daVoltage18,
|
|
|
|
daMiniA,
|
|
|
|
daMiniB,
|
2013-08-21 11:02:52 +02:00
|
|
|
daPositionN,
|
|
|
|
daPositionA,
|
2011-09-11 14:09:03 +02:00
|
|
|
daScr,
|
2002-10-06 10:25:42 +02:00
|
|
|
daCodes,
|
2013-08-21 11:02:52 +02:00
|
|
|
daWait,
|
2002-10-06 10:25:42 +02:00
|
|
|
};
|
|
|
|
enum { MaxDiseqcCodes = 6 };
|
|
|
|
private:
|
2010-02-06 15:56:01 +01:00
|
|
|
int devices;
|
2002-10-06 10:25:42 +02:00
|
|
|
int source;
|
|
|
|
int slof;
|
|
|
|
char polarization;
|
|
|
|
int lof;
|
2013-08-21 11:02:52 +02:00
|
|
|
mutable int position;
|
2011-09-11 14:09:03 +02:00
|
|
|
mutable int scrBank;
|
2002-10-06 10:25:42 +02:00
|
|
|
char *commands;
|
|
|
|
bool parsing;
|
2017-01-09 15:21:13 +01:00
|
|
|
int SetScrFrequency(int SatFrequency, const cScr *Scr, uint8_t *Codes) const;
|
2011-09-11 14:09:03 +02:00
|
|
|
int SetScrPin(const cScr *Scr, uint8_t *Codes) const;
|
2011-05-22 10:51:03 +02:00
|
|
|
const char *Wait(const char *s) const;
|
2013-08-21 11:02:52 +02:00
|
|
|
const char *GetPosition(const char *s) const;
|
2011-09-11 14:09:03 +02:00
|
|
|
const char *GetScrBank(const char *s) const;
|
2011-09-10 13:55:08 +02:00
|
|
|
const char *GetCodes(const char *s, uchar *Codes = NULL, uint8_t *MaxCodes = NULL) const;
|
2002-10-06 10:25:42 +02:00
|
|
|
public:
|
|
|
|
cDiseqc(void);
|
|
|
|
~cDiseqc();
|
|
|
|
bool Parse(const char *s);
|
2017-01-09 15:21:13 +01:00
|
|
|
eDiseqcActions Execute(const char **CurrentAction, uchar *Codes, uint8_t *MaxCodes, const cScr *Scr, int *Frequency) const;
|
2011-09-11 14:09:03 +02:00
|
|
|
///< Parses the DiSEqC commands and returns the appropriate action code
|
|
|
|
///< with every call. CurrentAction must be the address of a character pointer,
|
|
|
|
///< which is initialized to NULL. This pointer is used internally while parsing
|
|
|
|
///< the commands and shall not be modified once Execute() has been called with
|
|
|
|
///< it. Call Execute() repeatedly (always providing the same CurrentAction pointer)
|
|
|
|
///< until it returns daNone. After a successful execution of all commands
|
|
|
|
///< *CurrentAction points to the value 0x00.
|
|
|
|
///< If the current action consists of sending code bytes to the device, those
|
|
|
|
///< bytes will be copied into Codes. MaxCodes must be initialized to the maximum
|
|
|
|
///< number of bytes Codes can handle, and will be set to the actual number of
|
|
|
|
///< bytes copied to Codes upon return.
|
|
|
|
///< If this DiSEqC entry requires SCR, the given Scr will be used. This must
|
|
|
|
///< be a pointer returned from a previous call to cDiseqcs::Get().
|
|
|
|
///< Frequency must be the frequency the tuner will be tuned to, and will be
|
|
|
|
///< set to the proper SCR frequency upon return (if SCR is used).
|
2010-02-06 15:56:01 +01:00
|
|
|
int Devices(void) const { return devices; }
|
2013-08-21 11:02:52 +02:00
|
|
|
///< Returns an integer where each bit represents one of the system's devices.
|
|
|
|
///< If a bit is set, this DiSEqC sequence applies to the corresponding device.
|
2002-10-06 10:25:42 +02:00
|
|
|
int Source(void) const { return source; }
|
2013-08-21 11:02:52 +02:00
|
|
|
///< Returns the satellite source this DiSEqC sequence applies to.
|
2002-10-06 10:25:42 +02:00
|
|
|
int Slof(void) const { return slof; }
|
2013-08-21 11:02:52 +02:00
|
|
|
///< Returns the switch frequency of the LNB this DiSEqC sequence applies to.
|
2002-10-06 10:25:42 +02:00
|
|
|
char Polarization(void) const { return polarization; }
|
2013-08-21 11:02:52 +02:00
|
|
|
///< Returns the signal polarization this DiSEqC sequence applies to.
|
2002-10-06 10:25:42 +02:00
|
|
|
int Lof(void) const { return lof; }
|
2013-08-21 11:02:52 +02:00
|
|
|
///< Returns the local oscillator frequency of the LNB this DiSEqC sequence applies to.
|
|
|
|
int Position(void) const { return position; }
|
|
|
|
///< Indicates which positioning mode to use in order to move the dish to a given
|
|
|
|
///< satellite position. -1 means "no positioning" (i.e. fixed dish); 0 means the
|
|
|
|
///< positioner can be moved to any arbitrary satellite position (within its
|
|
|
|
///< limits); and a positive number means "move the dish to the position stored
|
|
|
|
///< under the given number".
|
|
|
|
bool IsScr(void) const { return scrBank >= 0; }
|
|
|
|
///< Returns true if this DiSEqC sequence uses Satellite Channel Routing.
|
2002-10-06 10:25:42 +02:00
|
|
|
const char *Commands(void) const { return commands; }
|
2013-08-21 11:02:52 +02:00
|
|
|
///< Returns a pointer to the actual commands of this DiSEqC sequence.
|
2002-10-06 10:25:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class cDiseqcs : public cConfig<cDiseqc> {
|
|
|
|
public:
|
2013-08-21 11:02:52 +02:00
|
|
|
bool Load(const char *FileName, bool AllowComments = false, bool MustExist = false);
|
2011-09-11 14:09:03 +02:00
|
|
|
const cDiseqc *Get(int Device, int Source, int Frequency, char Polarization, const cScr **Scr) const;
|
|
|
|
///< Selects a DiSEqC entry suitable for the given Device and tuning parameters.
|
|
|
|
///< If this DiSEqC entry requires SCR and the given *Scr is NULL
|
|
|
|
///< a free one will be selected from the Scrs and a pointer to that will
|
|
|
|
///< be returned in Scr. The caller shall memorize that pointer and reuse it in
|
|
|
|
///< subsequent calls.
|
|
|
|
///< Scr may be NULL for checking whether there is any DiSEqC entry for the
|
|
|
|
///< given transponder.
|
2002-10-06 10:25:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
extern cDiseqcs Diseqcs;
|
|
|
|
|
|
|
|
#endif //__DISEQC_H
|