| 1 |
|
| /* |
| 2 |
|
| * dvb_error.c |
| 3 |
|
| * |
| 4 |
|
| * Created on: 28 Apr 2010 |
| 5 |
|
| * Author: sdprice1 |
| 6 |
|
| */ |
| 7 |
|
| |
| 8 |
|
| #include <stdio.h> |
| 9 |
|
| #include <stdlib.h> |
| 10 |
|
| #include <unistd.h> |
| 11 |
|
| #include <string.h> |
| 12 |
|
| #include <errno.h> |
| 13 |
|
| #include <ctype.h> |
| 14 |
|
| //#include <fcntl.h> |
| 15 |
|
| //#include <inttypes.h> |
| 16 |
|
| //#include <sys/time.h> |
| 17 |
|
| //#include <sys/types.h> |
| 18 |
|
| //#include <sys/ioctl.h> |
| 19 |
|
| |
| 20 |
|
| #include "dvb_error.h" |
| 21 |
|
| |
| 22 |
|
| // ERRORS |
| 23 |
|
| enum DVB_error dvb_error_code = ERR_NONE ; |
| 24 |
|
| int dvb_errno = 0 ; |
| 25 |
|
| |
| 26 |
|
| static char *DVB_ERRORS[256] = { |
| 27 |
|
| [0 ... 255] = "UNKNOWN", |
| 28 |
|
| [-ERR_BUFFER_ZERO] = "unexpected empty buffer", |
| 29 |
|
| [-ERR_INVALID_ERR] = "error code is outside valid range", |
| 30 |
|
| [-ERR_MALLOC] = "malloc error", |
| 31 |
|
| [-ERR_IOCTL] = "ioctl error", |
| 32 |
|
| [-ERR_GENERIC] = "general error", |
| 33 |
|
| |
| 34 |
|
| [-ERR_NOSYNC] = "no sync byte found in transport stream", |
| 35 |
|
| [-ERR_BADSYNC] = "invalid sync byte found in transport stream", |
| 36 |
|
| [-ERR_TSERR] = "TS error flag set in transport stream", |
| 37 |
|
| [-ERR_SECTIONLEN] = "invalid PSI section length in transport stream", |
| 38 |
|
| [-ERR_PESHEAD] = "corrupted PES header in transport stream", |
| 39 |
|
| [-ERR_TSCORRUPT] = "corrupted transport stream", |
| 40 |
|
| |
| 41 |
|
| [-ERR_READ] = "read error", |
| 42 |
|
| [-ERR_SELECT] = "error waiting for data", |
| 43 |
|
| [-ERR_TIMEOUT] = "timed out waiting for data", |
| 44 |
|
| [-ERR_EOF] = "unexpected EOF", |
| 45 |
|
| [-ERR_OVERFLOW] = "dvb buffer overflow", |
| 46 |
|
| |
| 47 |
|
| [-ERR_FILE] = "file error", |
| 48 |
|
| [-ERR_FILE_SEEK] = "file seek error", |
| 49 |
|
| [-ERR_FILE_NO_PKTS] = "file no ts packets", |
| 50 |
|
| [-ERR_FILE_ZERO] = "file zero length", |
| 51 |
|
| |
| 52 |
|
| [-ERR_TUNING_TIMEOUT] = "frontend tuning timed out", |
| 53 |
|
| [-ERR_TUNING_TIMEOUT0] = "frontend is not tuned (no timeout specified)", |
| 54 |
|
| |
| 55 |
|
| [-ERR_DVB_DEV] = "DVB device error", |
| 56 |
|
| [-ERR_DEMUX_OPEN] = "DVB demux device busy", |
| 57 |
|
| [-ERR_DVR_OPEN] = "DVB recording device busy", |
| 58 |
|
| [-ERR_FE_OPEN] = "DVB frontend device busy", |
| 59 |
|
| [-ERR_SET_PES_FILTER] = "DVB unable to set PES filter", |
| 60 |
|
| [-ERR_REQ_SECTION] = "DVB unable to set section filter", |
| 61 |
|
| |
| 62 |
|
| [-ERR_DURATION] = "invalid recording duration parameter", |
| 63 |
|
| [-ERR_INVALID_TSREADER] = "invalid tsreader structure", |
| 64 |
|
| |
| 65 |
|
| |
| 66 |
|
| [-ERR_NONE] = "no error", |
| 67 |
|
| } ; |
| 68 |
|
| |
| 69 |
|
| |
| 70 |
|
| /*=============================================================================================*/ |
| 71 |
|
| |
| 72 |
|
| |
| 73 |
|
| /*=============================================================================================*/ |
| 74 |
|
| // PUBLIC |
| 75 |
|
| /*=============================================================================================*/ |
| 76 |
|
| |
| 77 |
|
| /* ----------------------------------------------------------------------- */ |
| 78 |
|
| // convert error code into a message string |
| 79 |
0 |
| char *dvb_error_str(enum DVB_error error) |
| 80 |
|
| { |
| 81 |
|
| static char error_str[256] ; |
| 82 |
|
| |
| 83 |
|
| // check range |
| 84 |
0 |
▶ | if ((error > 0) || (error < ERR_MAX)) |
Branch: 2 branches
| Branch | True | False | Total |
| if ((error > 0) || (error < ERR_MAX)) |
0 |
0 |
0 |
| if ((error > 0) || (error < ERR_MAX)) |
0 |
0 |
0 |
|
| 85 |
|
| { |
| 86 |
0 |
| sprintf(error_str, "%s %d .. %d (code = %d)", DVB_ERRORS[-ERR_INVALID_ERR], ERR_NONE, ERR_MAX, error) ; |
| 87 |
0 |
| return error_str ; |
| 88 |
|
| } |
| 89 |
|
| |
| 90 |
|
| // make code +ve |
| 91 |
0 |
| error = -error ; |
| 92 |
|
| |
| 93 |
|
| // lookup |
| 94 |
0 |
▶ | if ( (dvb_error_code != ERR_NONE) && dvb_errno ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( (dvb_error_code != ERR_NONE) && dvb_errno ) |
0 |
0 |
0 |
| if ( (dvb_error_code != ERR_NONE) && dvb_errno ) |
0 |
0 |
0 |
|
| 95 |
|
| { |
| 96 |
0 |
| sprintf(error_str, "%s : %s", DVB_ERRORS[error], strerror(dvb_errno)) ; |
| 97 |
|
| } |
| 98 |
|
| else |
| 99 |
|
| { |
| 100 |
0 |
| sprintf(error_str, "%s", DVB_ERRORS[error]) ; |
| 101 |
|
| } |
| 102 |
|
| |
| 103 |
0 |
| return error_str ; |
| 104 |
|
| } |
| 105 |
|
| |
| 106 |
|
| /* ----------------------------------------------------------------------- */ |
| 107 |
|
| // Clear errors |
| 108 |
8 |
| void dvb_error_clear() |
| 109 |
|
| { |
| 110 |
8 |
| errno = 0 ; |
| 111 |
8 |
| dvb_errno = 0 ; |
| 112 |
8 |
| dvb_error_code = ERR_NONE ; |
| 113 |
8 |
| } |
| 114 |
|
| |