1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

The DiSEqC codes are now copied in the call to cDiseqc::Execute()

This commit is contained in:
Klaus Schmidinger 2011-09-10 13:55:08 +02:00
parent 873b14ac0c
commit 78e89efee8
4 changed files with 32 additions and 31 deletions

View File

@ -6747,3 +6747,4 @@ Video Disk Recorder Revision History
- Fixed scaling subtitles in case the primary device's GetVideoSize() function doesn't - Fixed scaling subtitles in case the primary device's GetVideoSize() function doesn't
return actual values (thanks to Luca Olivetti). return actual values (thanks to Luca Olivetti).
- The DiSEqC codes are now copied in the call to cDiseqc::Execute().

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: diseqc.c 2.5 2011/08/06 10:32:18 kls Exp $ * $Id: diseqc.c 2.6 2011/09/10 13:38:38 kls Exp $
*/ */
#include "diseqc.h" #include "diseqc.h"
@ -23,7 +23,6 @@ cDiseqc::cDiseqc(void)
lof = 0; lof = 0;
commands = NULL; commands = NULL;
parsing = false; parsing = false;
numCodes = 0;
} }
cDiseqc::~cDiseqc() cDiseqc::~cDiseqc()
@ -60,7 +59,7 @@ bool cDiseqc::Parse(const char *s)
if (polarization == 'V' || polarization == 'H' || polarization == 'L' || polarization == 'R') { if (polarization == 'V' || polarization == 'H' || polarization == 'L' || polarization == 'R') {
parsing = true; parsing = true;
const char *CurrentAction = NULL; const char *CurrentAction = NULL;
while (Execute(&CurrentAction) != daNone) while (Execute(&CurrentAction, NULL, NULL) != daNone)
; ;
parsing = false; parsing = false;
result = !commands || !*CurrentAction; result = !commands || !*CurrentAction;
@ -89,7 +88,7 @@ const char *cDiseqc::Wait(const char *s) const
return NULL; return NULL;
} }
const char *cDiseqc::Codes(const char *s) const const char *cDiseqc::GetCodes(const char *s, uchar *Codes, uint8_t *MaxCodes) const
{ {
const char *e = strchr(s, ']'); const char *e = strchr(s, ']');
if (e) { if (e) {
@ -101,9 +100,13 @@ const char *cDiseqc::Codes(const char *s) const
char *p; char *p;
int n = strtol(t, &p, 16); int n = strtol(t, &p, 16);
if (!errno && p != t && 0 <= n && n <= 255) { if (!errno && p != t && 0 <= n && n <= 255) {
if (!parsing) { if (Codes) {
codes[NumCodes++] = uchar(n); if (NumCodes < *MaxCodes)
numCodes = NumCodes; Codes[NumCodes++] = uchar(n);
else {
esyslog("ERROR: too many codes in code sequence '%s'", s - 1);
return NULL;
}
} }
t = skipspace(p); t = skipspace(p);
} }
@ -117,6 +120,8 @@ const char *cDiseqc::Codes(const char *s) const
return NULL; return NULL;
} }
} }
if (MaxCodes)
*MaxCodes = NumCodes;
return e + 1; return e + 1;
} }
else else
@ -124,7 +129,7 @@ const char *cDiseqc::Codes(const char *s) const
return NULL; return NULL;
} }
cDiseqc::eDiseqcActions cDiseqc::Execute(const char **CurrentAction) const cDiseqc::eDiseqcActions cDiseqc::Execute(const char **CurrentAction, uchar *Codes, uint8_t *MaxCodes) const
{ {
if (!*CurrentAction) if (!*CurrentAction)
*CurrentAction = commands; *CurrentAction = commands;
@ -138,7 +143,7 @@ cDiseqc::eDiseqcActions cDiseqc::Execute(const char **CurrentAction) const
case 'A': return daMiniA; case 'A': return daMiniA;
case 'B': return daMiniB; case 'B': return daMiniB;
case 'W': *CurrentAction = Wait(*CurrentAction); break; case 'W': *CurrentAction = Wait(*CurrentAction); break;
case '[': *CurrentAction = Codes(*CurrentAction); return *CurrentAction ? daCodes : daNone; case '[': *CurrentAction = GetCodes(*CurrentAction, Codes, MaxCodes); return *CurrentAction ? daCodes : daNone;
default: return daNone; default: return daNone;
} }
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: diseqc.h 2.2 2011/05/22 10:35:38 kls Exp $ * $Id: diseqc.h 2.3 2011/09/10 13:36:50 kls Exp $
*/ */
#ifndef __DISEQC_H #ifndef __DISEQC_H
@ -33,15 +33,13 @@ private:
int lof; int lof;
char *commands; char *commands;
bool parsing; bool parsing;
mutable uchar codes[MaxDiseqcCodes];
mutable int numCodes;
const char *Wait(const char *s) const; const char *Wait(const char *s) const;
const char *Codes(const char *s) const; const char *GetCodes(const char *s, uchar *Codes = NULL, uint8_t *MaxCodes = NULL) const;
public: public:
cDiseqc(void); cDiseqc(void);
~cDiseqc(); ~cDiseqc();
bool Parse(const char *s); bool Parse(const char *s);
eDiseqcActions Execute(const char **CurrentAction) const; eDiseqcActions Execute(const char **CurrentAction, uchar *Codes, uint8_t *MaxCodes) const;
// Parses the DiSEqC commands and returns the appropriate action code // Parses the DiSEqC commands and returns the appropriate action code
// with every call. CurrentAction must be the address of a character pointer, // with every call. CurrentAction must be the address of a character pointer,
// which is initialized to NULL. This pointer is used internally while parsing // which is initialized to NULL. This pointer is used internally while parsing
@ -49,13 +47,16 @@ public:
// it. Call Execute() repeatedly (always providing the same CurrentAction pointer) // it. Call Execute() repeatedly (always providing the same CurrentAction pointer)
// until it returns daNone. After a successful execution of all commands // until it returns daNone. After a successful execution of all commands
// *CurrentAction points to the value 0x00. // *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.
int Devices(void) const { return devices; } int Devices(void) const { return devices; }
int Source(void) const { return source; } int Source(void) const { return source; }
int Slof(void) const { return slof; } int Slof(void) const { return slof; }
char Polarization(void) const { return polarization; } char Polarization(void) const { return polarization; }
int Lof(void) const { return lof; } int Lof(void) const { return lof; }
const char *Commands(void) const { return commands; } const char *Commands(void) const { return commands; }
const uchar *Codes(int &NumCodes) const { NumCodes = numCodes; return numCodes ? codes : NULL; }
}; };
class cDiseqcs : public cConfig<cDiseqc> { class cDiseqcs : public cConfig<cDiseqc> {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbdevice.c 2.43 2011/08/26 12:57:34 kls Exp $ * $Id: dvbdevice.c 2.44 2011/09/10 13:34:02 kls Exp $
*/ */
#include "dvbdevice.h" #include "dvbdevice.h"
@ -509,30 +509,24 @@ bool cDvbTuner::SetFrontend(void)
if (frontendType == SYS_DVBS || frontendType == SYS_DVBS2) { if (frontendType == SYS_DVBS || frontendType == SYS_DVBS2) {
unsigned int frequency = channel.Frequency(); unsigned int frequency = channel.Frequency();
if (Setup.DiSEqC) { if (Setup.DiSEqC) {
const cDiseqc *diseqc = Diseqcs.Get(device, channel.Source(), channel.Frequency(), dtp.Polarization()); const cDiseqc *diseqc = Diseqcs.Get(device, channel.Source(), frequency, dtp.Polarization());
if (diseqc) { if (diseqc) {
if (diseqc->Commands() && (!diseqcCommands || strcmp(diseqcCommands, diseqc->Commands()) != 0)) { if (diseqc->Commands() && (!diseqcCommands || strcmp(diseqcCommands, diseqc->Commands()) != 0)) {
cDiseqc::eDiseqcActions da; struct dvb_diseqc_master_cmd cmd;
for (const char *CurrentAction = NULL; (da = diseqc->Execute(&CurrentAction)) != cDiseqc::daNone; ) { const char *CurrentAction = NULL;
for (;;) {
cmd.msg_len = sizeof(cmd.msg);
cDiseqc::eDiseqcActions da = diseqc->Execute(&CurrentAction, cmd.msg, &cmd.msg_len);
if (da == cDiseqc::daNone)
break;
switch (da) { switch (da) {
case cDiseqc::daNone: break;
case cDiseqc::daToneOff: CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF)); break; case cDiseqc::daToneOff: CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_OFF)); break;
case cDiseqc::daToneOn: CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_ON)); break; case cDiseqc::daToneOn: CHECK(ioctl(fd_frontend, FE_SET_TONE, SEC_TONE_ON)); break;
case cDiseqc::daVoltage13: CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, SEC_VOLTAGE_13)); break; case cDiseqc::daVoltage13: CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, SEC_VOLTAGE_13)); break;
case cDiseqc::daVoltage18: CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, SEC_VOLTAGE_18)); break; case cDiseqc::daVoltage18: CHECK(ioctl(fd_frontend, FE_SET_VOLTAGE, SEC_VOLTAGE_18)); break;
case cDiseqc::daMiniA: CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_A)); break; case cDiseqc::daMiniA: CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_A)); break;
case cDiseqc::daMiniB: CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_B)); break; case cDiseqc::daMiniB: CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_BURST, SEC_MINI_B)); break;
case cDiseqc::daCodes: { case cDiseqc::daCodes: CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd)); break;
int n = 0;
const uchar *codes = diseqc->Codes(n);
if (codes) {
struct dvb_diseqc_master_cmd cmd;
cmd.msg_len = min(n, int(sizeof(cmd.msg)));
memcpy(cmd.msg, codes, cmd.msg_len);
CHECK(ioctl(fd_frontend, FE_DISEQC_SEND_MASTER_CMD, &cmd));
}
}
break;
default: esyslog("ERROR: unknown diseqc command %d", da); default: esyslog("ERROR: unknown diseqc command %d", da);
} }
} }