1 /*
2 ** =============================================================================
3 ** Copyright (c) 2016 Texas Instruments Inc.
4 **
5 ** This program is free software; you can redistribute it and/or modify it under
6 ** the terms of the GNU General Public License as published by the Free Software
7 ** Foundation; version 2.
8 **
9 ** This program is distributed in the hope that it will be useful, but WITHOUT
10 ** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 ** FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12 **
13 ** You should have received a copy of the GNU General Public License along with
14 ** this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15 ** Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 **
17 ** File:
18 ** system.c
19 **
20 ** Description:
21 ** system functions for TAS2555 factory test program
22 **
23 ** =============================================================================
24 */
26 #include "system.h"
28 #include <sys/wait.h>
29 #include <sys/types.h>
30 #include <stdio.h>
31 #include <unistd.h>
32 #include <stdlib.h>
34 pid_t sys_play_wav(char * pFile, char * pMode)
35 {
36 pid_t nProcess;
37 int nStatus, nTimeout;
38 char *pArgs[] = {AUDIO_PLAYER, pFile, NULL};
39 char *pEnv[] = {NULL};
41 if (0 == (nProcess = fork()))
42 {
43 if (execve(AUDIO_PLAYER, pArgs, pEnv) == -1)
44 {
45 printf("factorytest: Can't play %s. Please install %s. \n\r", pFile, AUDIO_PLAYER);
46 exit(-1);
47 }
48 }
50 sys_delay(500);
52 printf("factorytest: Started playback of %s\n\r", pFile);
54 return nProcess;
55 }
57 extern void sys_stop_wav(pid_t nProcess)
58 {
59 char *pEnv[] = {NULL};
61 printf("factorytest: Stop playback.\n\r");
63 kill(nProcess, SIGKILL);
64 }
66 extern void sys_delay(uint32_t delay_ms)
67 {
68 usleep(delay_ms * 1000);
69 }
71 extern double sys_get_ambient_temp(void)
72 {
73 return 0.0;
74 }
76 extern int sys_is_valid(char * pFile)
77 {
78 return 0;
79 }