From 4bc51699b9bba8a113b6e1862946768f779afe7d Mon Sep 17 00:00:00 2001 From: Joakim Hernberg Date: Tue, 9 Apr 2013 10:22:27 +0200 Subject: [PATCH 1/2] make diseqc tracing comprehensive --- src/dvb/diseqc.c | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) mode change 100644 => 100755 src/dvb/diseqc.c diff --git a/src/dvb/diseqc.c b/src/dvb/diseqc.c old mode 100644 new mode 100755 index 7b736f35..8f070bfb --- a/src/dvb/diseqc.c +++ b/src/dvb/diseqc.c @@ -20,6 +20,7 @@ int diseqc_send_msg(int fe_fd, __u8 framing_byte, __u8 address, __u8 cmd, __u8 data_1, __u8 data_2, __u8 data_3, __u8 msg_len) { + int err; struct dvb_diseqc_master_cmd message; tvhtrace("diseqc", "sending %X %X %X %X %X %X", @@ -32,7 +33,11 @@ diseqc_send_msg(int fe_fd, __u8 framing_byte, __u8 address, __u8 cmd, message.msg[4] = data_2; message.msg[5] = data_3; message.msg_len = msg_len; - return ioctl(fe_fd, FE_DISEQC_SEND_MASTER_CMD, &message); + if ((err = ioctl(fe_fd, FE_DISEQC_SEND_MASTER_CMD, &message))) { + return err; + tvhtrace("diseqc", "Error sending diseqc command"); + } + return 0; } int @@ -44,7 +49,7 @@ diseqc_setup(int fe_fd, int lnb_num, int voltage, int band, int k, err; tvhtrace("diseqc", - "fe_fd %i, lnb_num %i, voltage %i, band %i, version %i, repeats %i", + "diseqc_setup() called with: fe_fd=%i, lnb_num=%i, voltage=%i, band=%i, version=%i, repeats=%i", fe_fd, lnb_num, voltage, band, version, repeats); /* verify lnb number and diseqc data */ @@ -52,13 +57,18 @@ diseqc_setup(int fe_fd, int lnb_num, int voltage, int band, return -1; /* turn off continuous tone */ - if ((err = ioctl(fe_fd, FE_SET_TONE, SEC_TONE_OFF))) + tvhtrace("diseqc", "Turning off continuous tone"); + if ((err = ioctl(fe_fd, FE_SET_TONE, SEC_TONE_OFF))) { + tvhtrace("diseqc", "Error trying to turn off continuous tone"); return err; + } /* set lnb voltage */ - if ((err = ioctl(fe_fd, FE_SET_VOLTAGE, - (i/2) % 2 ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13))) + tvhtrace("diseqc", "Setting lnb voltage to %iV", (i/2) % 2 ? 18 : 13); + if ((err = ioctl(fe_fd, FE_SET_VOLTAGE, (i/2) % 2 ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13))) { + tvhtrace("diseqc", "Error setting lnb voltage"); return err; + } msleep(15); if (repeats == 0) { /* uncommited msg, wait 15ms, commited msg */ @@ -82,19 +92,31 @@ diseqc_setup(int fe_fd, int lnb_num, int voltage, int band, msleep(15); /* set toneburst */ - if ((err = ioctl(fe_fd, FE_DISEQC_SEND_BURST, - (i/4) % 2 ? SEC_MINI_B : SEC_MINI_A))) + tvhtrace("diseqc", (i/4) % 2 ? "Sending mini diseqc B" : "Sending mini diseqc A"); + if ((err = ioctl(fe_fd, FE_DISEQC_SEND_BURST, (i/4) % 2 ? SEC_MINI_B : SEC_MINI_A))) { + tvhtrace("diseqc", "Error sending mini diseqc command"); return err; + } msleep(15); /* set continuous tone */ - if ((err = ioctl(fe_fd, FE_SET_TONE, i % 2 ? SEC_TONE_ON : SEC_TONE_OFF))) + tvhtrace("diseqc", i % 2 ? "Setting continous 22KHz to on" : "Setting continous 22KHz to off"); + if ((err = ioctl(fe_fd, FE_SET_TONE, i % 2 ? SEC_TONE_ON : SEC_TONE_OFF))) { + tvhtrace("diseqc", "Error setting continuous tone"); return err; + } return 0; } int diseqc_voltage_off(int fe_fd) { - return ioctl(fe_fd, FE_SET_VOLTAGE, SEC_VOLTAGE_OFF); + int err; + + tvhtrace("diseqc", "Sending diseqc voltage off command"); + if ((err = ioctl(fe_fd, FE_SET_VOLTAGE, SEC_VOLTAGE_OFF))) { + tvhtrace("diseqc", "Error sending diseqc voltage off command"); + return err; + } + return 0; } From c00e5e0af4915c297ef0ea2ddb5b47ee6ac03357 Mon Sep 17 00:00:00 2001 From: Joakim Hernberg Date: Tue, 9 Apr 2013 11:00:32 +0200 Subject: [PATCH 2/2] tidy up trace spamming --- src/dvb/diseqc.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/dvb/diseqc.c b/src/dvb/diseqc.c index 8f070bfb..29c948d3 100755 --- a/src/dvb/diseqc.c +++ b/src/dvb/diseqc.c @@ -34,8 +34,8 @@ diseqc_send_msg(int fe_fd, __u8 framing_byte, __u8 address, __u8 cmd, message.msg[5] = data_3; message.msg_len = msg_len; if ((err = ioctl(fe_fd, FE_DISEQC_SEND_MASTER_CMD, &message))) { + tvhlog(LOG_ERR, "diseqc", "error sending diseqc command"); return err; - tvhtrace("diseqc", "Error sending diseqc command"); } return 0; } @@ -49,7 +49,7 @@ diseqc_setup(int fe_fd, int lnb_num, int voltage, int band, int k, err; tvhtrace("diseqc", - "diseqc_setup() called with: fe_fd=%i, lnb_num=%i, voltage=%i, band=%i, version=%i, repeats=%i", + "fe_fd=%i, lnb_num=%i, voltage=%i, band=%i, version=%i, repeats=%i", fe_fd, lnb_num, voltage, band, version, repeats); /* verify lnb number and diseqc data */ @@ -57,16 +57,16 @@ diseqc_setup(int fe_fd, int lnb_num, int voltage, int band, return -1; /* turn off continuous tone */ - tvhtrace("diseqc", "Turning off continuous tone"); + tvhtrace("diseqc", "disabling continuous tone"); if ((err = ioctl(fe_fd, FE_SET_TONE, SEC_TONE_OFF))) { - tvhtrace("diseqc", "Error trying to turn off continuous tone"); + tvhlog(LOG_ERR, "diseqc", "error trying to turn off continuous tone"); return err; } /* set lnb voltage */ - tvhtrace("diseqc", "Setting lnb voltage to %iV", (i/2) % 2 ? 18 : 13); + tvhtrace("diseqc", "setting lnb voltage to %iV", (i/2) % 2 ? 18 : 13); if ((err = ioctl(fe_fd, FE_SET_VOLTAGE, (i/2) % 2 ? SEC_VOLTAGE_18 : SEC_VOLTAGE_13))) { - tvhtrace("diseqc", "Error setting lnb voltage"); + tvhlog(LOG_ERR, "diseqc", "error setting lnb voltage"); return err; } msleep(15); @@ -92,17 +92,17 @@ diseqc_setup(int fe_fd, int lnb_num, int voltage, int band, msleep(15); /* set toneburst */ - tvhtrace("diseqc", (i/4) % 2 ? "Sending mini diseqc B" : "Sending mini diseqc A"); + tvhtrace("diseqc", (i/4) % 2 ? "sending mini diseqc B" : "sending mini diseqc A"); if ((err = ioctl(fe_fd, FE_DISEQC_SEND_BURST, (i/4) % 2 ? SEC_MINI_B : SEC_MINI_A))) { - tvhtrace("diseqc", "Error sending mini diseqc command"); + tvhlog(LOG_ERR, "diseqc", "error sending mini diseqc command"); return err; } msleep(15); /* set continuous tone */ - tvhtrace("diseqc", i % 2 ? "Setting continous 22KHz to on" : "Setting continous 22KHz to off"); + tvhtrace("diseqc", i % 2 ? "enabling continous tone" : "disabling continuous tone"); if ((err = ioctl(fe_fd, FE_SET_TONE, i % 2 ? SEC_TONE_ON : SEC_TONE_OFF))) { - tvhtrace("diseqc", "Error setting continuous tone"); + tvhlog(LOG_ERR, "diseqc", "error setting continuous tone"); return err; } return 0; @@ -113,9 +113,9 @@ diseqc_voltage_off(int fe_fd) { int err; - tvhtrace("diseqc", "Sending diseqc voltage off command"); + tvhtrace("diseqc", "sending diseqc voltage off command"); if ((err = ioctl(fe_fd, FE_SET_VOLTAGE, SEC_VOLTAGE_OFF))) { - tvhtrace("diseqc", "Error sending diseqc voltage off command"); + tvhlog(LOG_ERR, "diseqc", "error sending diseqc voltage off command"); return err; } return 0;