test_front.c 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. /*
  2. * test_front.c - Test program for new API
  3. *
  4. * Copyright (C) 2000 Ralph Metzler <ralph@convergence.de>
  5. * & Marcus Metzler <marcus@convergence.de>
  6. for convergence integrated media GmbH
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public License
  10. * as published by the Free Software Foundation; either version 2.1
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. *
  22. */
  23. #include <sys/ioctl.h>
  24. #include <stdio.h>
  25. #include <stdint.h>
  26. #include <sys/types.h>
  27. #include <sys/stat.h>
  28. #include <fcntl.h>
  29. #include <time.h>
  30. #include <unistd.h>
  31. #include <ost/dmx.h>
  32. #include <ost/frontend_old.h>
  33. #include <ost/sec.h>
  34. #include <ost/audio.h>
  35. #include <sys/poll.h>
  36. int OSTSelftest(int fd)
  37. {
  38. int ans;
  39. if ((ans = ioctl(fd,OST_SELFTEST,0)) < 0) {
  40. perror("OST SELF TEST: ");
  41. return -1;
  42. }
  43. return 0;
  44. }
  45. int OSTSetPowerState(int fd, uint32_t state)
  46. {
  47. int ans;
  48. if ((ans = ioctl(fd,OST_SET_POWER_STATE,state)) < 0) {
  49. perror("OST SET POWER STATE: ");
  50. return -1;
  51. }
  52. return 0;
  53. }
  54. int OSTGetPowerState(int fd, uint32_t *state)
  55. {
  56. int ans;
  57. if ((ans = ioctl(fd,OST_GET_POWER_STATE,state)) < 0) {
  58. perror("OST GET POWER STATE: ");
  59. return -1;
  60. }
  61. switch(*state){
  62. case OST_POWER_ON:
  63. printf("POWER ON (%d)\n",*state);
  64. break;
  65. case OST_POWER_STANDBY:
  66. printf("POWER STANDBY (%d)\n",*state);
  67. break;
  68. case OST_POWER_SUSPEND:
  69. printf("POWER SUSPEND (%d)\n",*state);
  70. break;
  71. case OST_POWER_OFF:
  72. printf("POWER OFF (%d)\n",*state);
  73. break;
  74. default:
  75. printf("unknown (%d)\n",*state);
  76. break;
  77. }
  78. return 0;
  79. }
  80. int FEReadStatus(int fd)
  81. {
  82. int ans;
  83. feStatus stat;
  84. if ((ans = ioctl(fd,FE_READ_STATUS,&stat)) < 0) {
  85. perror("FE READ STATUS: ");
  86. return -1;
  87. }
  88. if (stat & FE_HAS_POWER)
  89. printf("FE HAS POWER\n");
  90. if (stat & FE_HAS_SIGNAL)
  91. printf("FE HAS SIGNAL\n");
  92. if (stat & QPSK_SPECTRUM_INV)
  93. printf("QPSK SPEKTRUM INV\n");
  94. return 0;
  95. }
  96. int FEReadBER(int fd, uint32_t *ber)
  97. {
  98. int ans;
  99. if ((ans = ioctl(fd,FE_READ_BER, ber)) < 0) {
  100. perror("FE READ_BER: ");
  101. return -1;
  102. }
  103. printf("BER: %d\n",*ber);
  104. return 0;
  105. }
  106. int FEReadSignalStrength(int fd, int32_t *strength)
  107. {
  108. int ans;
  109. if ((ans = ioctl(fd,FE_READ_SIGNAL_STRENGTH, strength)) < 0) {
  110. perror("FE READ SIGNAL STRENGTH: ");
  111. return -1;
  112. }
  113. printf("SIGNAL STRENGTH: %d\n",*strength);
  114. return 0;
  115. }
  116. int FEReadSNR(int fd, int32_t *snr)
  117. {
  118. int ans;
  119. if ((ans = ioctl(fd,FE_READ_SNR, snr)) < 0) {
  120. perror("FE READ_SNR: ");
  121. return -1;
  122. }
  123. printf("SNR: %d\n",*snr);
  124. return 0;
  125. }
  126. int FEReadUncorrectedBlocks(int fd, uint32_t *ucb)
  127. {
  128. int ans;
  129. if ((ans = ioctl(fd,FE_READ_UNCORRECTED_BLOCKS, ucb)) < 0) {
  130. perror("FE READ UNCORRECTED BLOCKS: ");
  131. return -1;
  132. }
  133. printf("UBLOCKS: %d\n",*ucb);
  134. return 0;
  135. }
  136. int FEGetNextFrequency(int fd, uint32_t *nfr)
  137. {
  138. int ans;
  139. if ((ans = ioctl(fd,FE_GET_NEXT_FREQUENCY, nfr)) < 0) {
  140. perror("FE GET NEXT FREQUENCY: ");
  141. return -1;
  142. }
  143. printf("Next Frequency: %d\n",*nfr);
  144. return 0;
  145. }
  146. int FEGetNextSymbolRate(int fd, uint32_t *nsr)
  147. {
  148. int ans;
  149. if ((ans = ioctl(fd,FE_GET_NEXT_SYMBOL_RATE, nsr)) < 0) {
  150. perror("FE GET NEXT SYMBOL RATE: ");
  151. return -1;
  152. }
  153. printf("Next Symbol Rate: %d\n",*nsr);
  154. return 0;
  155. }
  156. int QPSKTune(int fd, struct qpskParameters *param)
  157. {
  158. int ans;
  159. if ((ans = ioctl(fd,QPSK_TUNE, param)) < 0) {
  160. perror("QPSK TUNE: ");
  161. return -1;
  162. }
  163. return 0;
  164. }
  165. int QPSKGetEvent (int fd, struct qpskEvent *event)
  166. {
  167. int ans;
  168. if ((ans = ioctl(fd,QPSK_GET_EVENT, event)) < 0) {
  169. perror("QPSK GET EVENT: ");
  170. return -1;
  171. }
  172. return 0;
  173. }
  174. int QPSKFEInfo (int fd, struct qpskFrontendInfo *info)
  175. {
  176. int ans;
  177. if ((ans = ioctl(fd,QPSK_FE_INFO, info)) < 0) {
  178. perror("QPSK FE INFO: ");
  179. return -1;
  180. }
  181. printf("min Frequency : %d\n", info->minFrequency);
  182. printf("max Frequency : %d\n", info->maxFrequency);
  183. printf("min Symbol Rate : %d\n", info->minSymbolRate);
  184. printf("max Symbol Rate : %d\n", info->maxSymbolRate);
  185. printf("Hardware Type : %d\n", info->hwType);
  186. printf("Hardware Version: %d\n", info->hwVersion);
  187. return 0;
  188. }
  189. int SecGetStatus (int fd, struct secStatus *state)
  190. {
  191. int ans;
  192. if ((ans = ioctl(fd,SEC_GET_STATUS, state)) < 0) {
  193. perror("QPSK GET EVENT: ");
  194. return -1;
  195. }
  196. switch (state->busMode){
  197. case SEC_BUS_IDLE:
  198. printf("SEC BUS MODE: IDLE (%d)\n",state->busMode);
  199. break;
  200. case SEC_BUS_BUSY:
  201. printf("SEC BUS MODE: BUSY (%d)\n",state->busMode);
  202. break;
  203. case SEC_BUS_OFF:
  204. printf("SEC BUS MODE: OFF (%d)\n",state->busMode);
  205. break;
  206. case SEC_BUS_OVERLOAD:
  207. printf("SEC BUS MODE: OVERLOAD (%d)\n",state->busMode);
  208. break;
  209. default:
  210. printf("SEC BUS MODE: unknown (%d)\n",state->busMode);
  211. break;
  212. }
  213. switch (state->selVolt){
  214. case SEC_VOLTAGE_OFF:
  215. printf("SEC VOLTAGE: OFF (%d)\n",state->selVolt);
  216. break;
  217. case SEC_VOLTAGE_LT:
  218. printf("SEC VOLTAGE: LT (%d)\n",state->selVolt);
  219. break;
  220. case SEC_VOLTAGE_13:
  221. printf("SEC VOLTAGE: 13 (%d)\n",state->selVolt);
  222. break;
  223. case SEC_VOLTAGE_13_5:
  224. printf("SEC VOLTAGE: 13.5 (%d)\n",state->selVolt);
  225. break;
  226. case SEC_VOLTAGE_18:
  227. printf("SEC VOLTAGE: 18 (%d)\n",state->selVolt);
  228. break;
  229. case SEC_VOLTAGE_18_5:
  230. printf("SEC VOLTAGE: 18.5 (%d)\n",state->selVolt);
  231. break;
  232. default:
  233. printf("SEC VOLTAGE: unknown (%d)\n",state->selVolt);
  234. break;
  235. }
  236. printf("SEC CONT TONE: %s\n", (state->contTone ? "ON" : "OFF"));
  237. return 0;
  238. }
  239. main(int argc, char **argv)
  240. {
  241. int fd,fd_sec;
  242. uint32_t state;
  243. int32_t strength;
  244. struct qpskFrontendInfo info;
  245. struct secStatus sec_state;
  246. if ((fd = open("/dev/ost/qpskfe",O_RDWR)) < 0){
  247. perror("FRONTEND DEVICE: ");
  248. return -1;
  249. }
  250. if ((fd_sec = open("/dev/ost/sec",O_RDWR)) < 0){
  251. perror("SEC DEVICE: ");
  252. return -1;
  253. }
  254. OSTSelftest(fd);
  255. OSTSetPowerState(fd, OST_POWER_ON);
  256. OSTGetPowerState(fd, &state);
  257. FEReadStatus(fd);
  258. FEReadBER(fd, &state);
  259. FEReadSignalStrength(fd, &strength);
  260. FEReadSNR(fd, &state);
  261. FEReadUncorrectedBlocks(fd, &state);
  262. state = 12567000;
  263. FEGetNextFrequency(fd, &state);
  264. FEGetNextSymbolRate(fd, &state);
  265. QPSKFEInfo (fd, &info);
  266. SecGetStatus (fd_sec, &sec_state);
  267. close(fd);
  268. close(fd_sec);
  269. }