summaryrefslogtreecommitdiff
Diffstat
-rw-r--r--tv_callback.h7
-rw-r--r--tv_input.cpp96
-rw-r--r--tvapi/android/include/ITv.h34
-rw-r--r--tvapi/android/include/ITvClient.h12
-rw-r--r--tvapi/android/include/ITvService.h18
-rw-r--r--tvapi/android/include/TvClient.h5
-rw-r--r--tvapi/android/include/tvcmd.h1180
-rw-r--r--tvapi/android/jni/cfbc_jni.cpp214
-rw-r--r--tvapi/android/jni/cfbc_test.cpp64
-rw-r--r--tvapi/android/jni/com_droidlogic_app_tv_TvControlManager.cpp666
-rw-r--r--tvapi/android/libtvbinder/ITv.cpp246
-rw-r--r--tvapi/android/libtvbinder/ITvClient.cpp78
-rw-r--r--tvapi/android/libtvbinder/ITvService.cpp56
-rw-r--r--tvapi/android/libtvbinder/TvClient.cpp54
-rw-r--r--tvapi/android/tv/TvPlay.cpp36
-rw-r--r--tvapi/android/tv/TvPlay.h2
-rw-r--r--tvapi/android/tvserver/TvService.cpp8700
-rw-r--r--tvapi/android/tvserver/TvService.h107
-rw-r--r--tvapi/android/tvserver/main.cpp12
-rw-r--r--tvapi/android/tvserver/tv_callback.h25
-rw-r--r--tvapi/libtv/audio/CAudioCustomerCtrl.cpp170
-rw-r--r--tvapi/libtv/audio/CAudioCustomerCtrl.h32
-rw-r--r--tvapi/libtv/audio/CTvAudio.h52
-rw-r--r--tvapi/libtv/audio/audio_alsa.cpp1004
-rw-r--r--tvapi/libtv/audio/audio_alsa.h164
-rw-r--r--tvapi/libtv/audio/audio_effect.cpp82
-rw-r--r--tvapi/libtv/audio/audio_effect.h34
-rw-r--r--tvapi/libtv/include/amstream.h142
-rw-r--r--tvapi/libtv/include/cm.h188
-rw-r--r--tvapi/libtv/include/hdmirx_cec.h492
-rw-r--r--tvapi/libtv/include/ve.h342
-rw-r--r--tvapi/libtv/tv/AutoBackLight.cpp280
-rw-r--r--tvapi/libtv/tv/AutoBackLight.h44
-rw-r--r--tvapi/libtv/tv/CAutoPQparam.cpp172
-rw-r--r--tvapi/libtv/tv/CAutoPQparam.h26
-rw-r--r--tvapi/libtv/tv/CAv.cpp612
-rw-r--r--tvapi/libtv/tv/CAv.h188
-rw-r--r--tvapi/libtv/tv/CFbcCommunication.cpp2670
-rw-r--r--tvapi/libtv/tv/CFbcCommunication.h716
-rw-r--r--tvapi/libtv/tv/CFrontEnd.cpp964
-rw-r--r--tvapi/libtv/tv/CFrontEnd.h236
-rw-r--r--tvapi/libtv/tv/CTv.cpp2174
-rw-r--r--tvapi/libtv/tv/CTv.h1470
-rw-r--r--tvapi/libtv/tv/CTvBooking.cpp170
-rw-r--r--tvapi/libtv/tv/CTvBooking.h94
-rw-r--r--tvapi/libtv/tv/CTvDmx.cpp8
-rw-r--r--tvapi/libtv/tv/CTvDmx.h12
-rw-r--r--tvapi/libtv/tv/CTvEpg.cpp258
-rw-r--r--tvapi/libtv/tv/CTvEpg.h276
-rw-r--r--tvapi/libtv/tv/CTvEv.cpp2
-rw-r--r--tvapi/libtv/tv/CTvEv.h322
-rw-r--r--tvapi/libtv/tv/CTvRecord.cpp368
-rw-r--r--tvapi/libtv/tv/CTvRecord.h70
-rw-r--r--tvapi/libtv/tv/CTvScanner.cpp1934
-rw-r--r--tvapi/libtv/tv/CTvScanner.h418
-rw-r--r--tvapi/libtv/tv/CTvScreenCapture.cpp1228
-rw-r--r--tvapi/libtv/tv/CTvScreenCapture.h142
-rw-r--r--tvapi/libtv/tv/CTvSubtitle.cpp708
-rw-r--r--tvapi/libtv/tv/CTvSubtitle.h430
-rw-r--r--tvapi/libtv/tv/CTvTime.h134
-rw-r--r--tvapi/libtv/tv/CTvVchipCheck.cpp250
-rw-r--r--tvapi/libtv/tv/CTvVchipCheck.h40
-rw-r--r--tvapi/libtv/tv/CUpgradeFBC.cpp974
-rw-r--r--tvapi/libtv/tv/CUpgradeFBC.h104
-rw-r--r--tvapi/libtv/tv/ScreenCatch.cpp638
-rw-r--r--tvapi/libtv/tvconfig/CIniFile.cpp558
-rw-r--r--tvapi/libtv/tvconfig/CIniFile.h76
-rw-r--r--tvapi/libtv/tvconfig/tvconfig.cpp28
-rw-r--r--tvapi/libtv/tvdb/CTvChannel.cpp408
-rw-r--r--tvapi/libtv/tvdb/CTvChannel.h478
-rw-r--r--tvapi/libtv/tvdb/CTvDatabase.cpp302
-rw-r--r--tvapi/libtv/tvdb/CTvDatabase.h112
-rw-r--r--tvapi/libtv/tvdb/CTvDimension.cpp714
-rw-r--r--tvapi/libtv/tvdb/CTvDimension.h134
-rw-r--r--tvapi/libtv/tvdb/CTvEvent.cpp322
-rw-r--r--tvapi/libtv/tvdb/CTvEvent.h112
-rw-r--r--tvapi/libtv/tvdb/CTvGroup.cpp4
-rw-r--r--tvapi/libtv/tvdb/CTvGroup.h14
-rw-r--r--tvapi/libtv/tvdb/CTvProgram.cpp1322
-rw-r--r--tvapi/libtv/tvdb/CTvProgram.h988
-rw-r--r--tvapi/libtv/tvdb/CTvRegion.cpp228
-rw-r--r--tvapi/libtv/tvdb/CTvRegion.h30
-rw-r--r--tvapi/libtv/tvin/CHDMIRxCEC.cpp830
-rw-r--r--tvapi/libtv/tvin/CSourceConnectDetect.cpp438
-rw-r--r--tvapi/libtv/tvin/CSourceConnectDetect.h76
-rw-r--r--tvapi/libtv/tvin/CTvin.cpp4452
-rw-r--r--tvapi/libtv/tvin/CTvin.h2116
-rw-r--r--tvapi/libtv/tvsetting/CBlobDevice.cpp6
-rw-r--r--tvapi/libtv/tvsetting/CBlobDevice.h72
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceE2prom.cpp12
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceE2prom.h48
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceFile.cpp66
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceFile.h20
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceRam.cpp146
-rw-r--r--tvapi/libtv/tvsetting/CBlobDeviceRam.h40
-rw-r--r--tvapi/libtv/tvsetting/CTvSetting.cpp2168
-rw-r--r--tvapi/libtv/tvsetting/CTvSettingDeviceFactory.cpp38
-rw-r--r--tvapi/libtv/tvsetting/CTvSettingDeviceFactory.h8
-rw-r--r--tvapi/libtv/tvsetting/TvKeyData.cpp1792
-rw-r--r--tvapi/libtv/tvsetting/audio_cfg.cpp958
-rw-r--r--tvapi/libtv/tvutils/CCondition.h84
-rw-r--r--tvapi/libtv/tvutils/CFile.cpp261
-rw-r--r--tvapi/libtv/tvutils/CFile.h50
-rw-r--r--tvapi/libtv/tvutils/CHdmiCecCmd.cpp6
-rw-r--r--tvapi/libtv/tvutils/CHdmiCecCmd.h6
-rw-r--r--tvapi/libtv/tvutils/CMsgQueue.cpp146
-rw-r--r--tvapi/libtv/tvutils/CMsgQueue.h40
-rw-r--r--tvapi/libtv/tvutils/CMutex.h112
-rw-r--r--tvapi/libtv/tvutils/CSerialCommunication.cpp118
-rw-r--r--tvapi/libtv/tvutils/CSerialCommunication.h60
-rw-r--r--tvapi/libtv/tvutils/CSerialPort.cpp568
-rw-r--r--tvapi/libtv/tvutils/CSerialPort.h42
-rw-r--r--tvapi/libtv/tvutils/CSqlite.cpp126
-rw-r--r--tvapi/libtv/tvutils/CSqlite.h288
-rw-r--r--tvapi/libtv/tvutils/CThread.cpp212
-rw-r--r--tvapi/libtv/tvutils/CThread.h76
-rw-r--r--tvapi/libtv/tvutils/CTvInput.cpp204
-rw-r--r--tvapi/libtv/tvutils/CTvInput.h46
-rw-r--r--tvapi/libtv/tvutils/serial_base.cpp560
-rw-r--r--tvapi/libtv/tvutils/serial_operate.cpp336
-rw-r--r--tvapi/libtv/tvutils/serial_operate.h42
-rw-r--r--tvapi/libtv/tvutils/tvutils.cpp2813
-rw-r--r--tvapi/libtv/tvutils/tvutils.h44
-rw-r--r--tvapi/libtv/tvutils/zepoll.cpp66
-rw-r--r--tvapi/libtv/tvutils/zepoll.h54
-rw-r--r--tvapi/libtv/version/version.cpp50
-rw-r--r--tvapi/libtv/vpp/CPQdb.cpp618
-rw-r--r--tvapi/libtv/vpp/CPQdb.h232
-rw-r--r--tvapi/libtv/vpp/CVpp.cpp724
-rw-r--r--tvapi/libtv/vpp/CVpp.h676
-rw-r--r--tvapi/libtv/vpp/pqdata.cpp216
-rw-r--r--tvapi/tvtests/comm_test.cpp42
-rw-r--r--tvapi/tvtests/ssm_test.cpp320
-rw-r--r--tvapi/tvtests/tvconfig_test.cpp560
134 files changed, 31073 insertions, 30287 deletions
diff --git a/tvapi/libtv/tvutils/CSerialPort.cpp b/tvapi/libtv/tvutils/CSerialPort.cpp
index f8e9a57..f634b04 100644
--- a/tvapi/libtv/tvutils/CSerialPort.cpp
+++ b/tvapi/libtv/tvutils/CSerialPort.cpp
@@ -15,7 +15,7 @@
CSerialPort::CSerialPort()
{
- mDevId = -1;
+ mDevId = -1;
}
//close it
CSerialPort::~CSerialPort()
@@ -24,334 +24,334 @@ CSerialPort::~CSerialPort()
int CSerialPort::OpenDevice(int serial_dev_id)
{
- int tmp_ret = 0;
- const char *dev_file_name = NULL;
-
- if (getFd() < 0) {
- if (serial_dev_id == SERIAL_A) {
- dev_file_name = DEV_PATH_S0;
- } else if (serial_dev_id == SERIAL_B) {
- dev_file_name = DEV_PATH_S1;
- } else if (serial_dev_id == SERIAL_C) {
- dev_file_name = DEV_PATH_S2;
- }
-
- if (dev_file_name != NULL) {
- mDevId = serial_dev_id;
- tmp_ret = openFile(dev_file_name);
- }
- }
-
- return tmp_ret;
+ int tmp_ret = 0;
+ const char *dev_file_name = NULL;
+
+ if (getFd() < 0) {
+ if (serial_dev_id == SERIAL_A) {
+ dev_file_name = DEV_PATH_S0;
+ } else if (serial_dev_id == SERIAL_B) {
+ dev_file_name = DEV_PATH_S1;
+ } else if (serial_dev_id == SERIAL_C) {
+ dev_file_name = DEV_PATH_S2;
+ }
+
+ if (dev_file_name != NULL) {
+ mDevId = serial_dev_id;
+ tmp_ret = openFile(dev_file_name);
+ }
+ }
+
+ return tmp_ret;
}
int CSerialPort::CloseDevice()
{
- mDevId = -1;
- closeFile();
+ mDevId = -1;
+ closeFile();
- return 0;
+ return 0;
}
void CSerialPort::set_speed (int fd, int speed)
{
- int i;
- int status;
- struct termios Opt;
- tcgetattr (fd, &Opt);
- for (i = 0; i < sizeof (speed_arr) / sizeof (int); i++) {
- if (speed == name_arr[i]) {
- tcflush (fd, TCIOFLUSH);
- cfsetispeed (&Opt, speed_arr[i]);
- cfsetospeed (&Opt, speed_arr[i]);
- status = tcsetattr (fd, TCSANOW, &Opt);
- if (status != 0) {
- perror ("tcsetattr fd1");
- return;
- }
- tcflush (fd, TCIOFLUSH);
- }
- }
+ int i;
+ int status;
+ struct termios Opt;
+ tcgetattr (fd, &Opt);
+ for (i = 0; i < sizeof (speed_arr) / sizeof (int); i++) {
+ if (speed == name_arr[i]) {
+ tcflush (fd, TCIOFLUSH);
+ cfsetispeed (&Opt, speed_arr[i]);
+ cfsetospeed (&Opt, speed_arr[i]);
+ status = tcsetattr (fd, TCSANOW, &Opt);
+ if (status != 0) {
+ perror ("tcsetattr fd1");
+ return;
+ }
+ tcflush (fd, TCIOFLUSH);
+ }
+ }
}
int CSerialPort::set_Parity (int fd, int databits, int stopbits, int parity)
{
- struct termios options;
- if (tcgetattr (fd, &options) != 0) {
- perror ("SetupSerial 1");
- return (0);
- }
- options.c_cflag &= ~CSIZE;
- switch (databits) {
- case 7:
- options.c_cflag |= CS7;
- break;
- case 8:
- options.c_cflag |= CS8;
- break;
- default:
- fprintf (stderr, "Unsupported data size\n");
- return (0);
- }
- switch (parity) {
- case 'n':
- case 'N':
- options.c_cflag &= ~PARENB; /* Clear parity enable */
- options.c_iflag &= ~INPCK; /* Enable parity checking */
- break;
- case 'o':
- case 'O':
- options.c_cflag |= (PARODD | PARENB);
- options.c_iflag |= INPCK; /* Disnable parity checking */
- break;
- case 'e':
- case 'E':
- options.c_cflag |= PARENB; /* Enable parity */
- options.c_cflag &= ~PARODD;
- options.c_iflag |= INPCK; /* Disnable parity checking */
- break;
- case 'S':
- case 's': /*as no parity */
- options.c_cflag &= ~PARENB;
- options.c_cflag &= ~CSTOPB;
- break;
- default:
- fprintf (stderr, "Unsupported parity\n");
- return (0);
- }
-
- switch (stopbits) {
- case 1:
- options.c_cflag &= ~CSTOPB;
- break;
- case 2:
- options.c_cflag |= CSTOPB;
- break;
- default:
- fprintf (stderr, "Unsupported stop bits\n");
- return (0);
- }
- /* Set input parity option */
- if (parity != 'n')
- options.c_iflag |= INPCK;
- tcflush (fd, TCIFLUSH);
- options.c_cc[VTIME] = 150;
- options.c_cc[VMIN] = 0; /* Update the options and do it NOW */
- //qd to set raw mode, which is copied from web
- options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
- | INLCR | IGNCR | ICRNL | IXON);
- options.c_oflag &= ~OPOST;
- options.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
- options.c_cflag &= ~(CSIZE | PARENB);
- options.c_cflag |= CS8;
-
- if (tcsetattr (fd, TCSANOW, &options) != 0) {
- perror ("SetupSerial 3");
- return (0);
- }
- return (1);
+ struct termios options;
+ if (tcgetattr (fd, &options) != 0) {
+ perror ("SetupSerial 1");
+ return (0);
+ }
+ options.c_cflag &= ~CSIZE;
+ switch (databits) {
+ case 7:
+ options.c_cflag |= CS7;
+ break;
+ case 8:
+ options.c_cflag |= CS8;
+ break;
+ default:
+ fprintf (stderr, "Unsupported data size\n");
+ return (0);
+ }
+ switch (parity) {
+ case 'n':
+ case 'N':
+ options.c_cflag &= ~PARENB; /* Clear parity enable */
+ options.c_iflag &= ~INPCK; /* Enable parity checking */
+ break;
+ case 'o':
+ case 'O':
+ options.c_cflag |= (PARODD | PARENB);
+ options.c_iflag |= INPCK; /* Disnable parity checking */
+ break;
+ case 'e':
+ case 'E':
+ options.c_cflag |= PARENB; /* Enable parity */
+ options.c_cflag &= ~PARODD;
+ options.c_iflag |= INPCK; /* Disnable parity checking */
+ break;
+ case 'S':
+ case 's': /*as no parity */
+ options.c_cflag &= ~PARENB;
+ options.c_cflag &= ~CSTOPB;
+ break;
+ default:
+ fprintf (stderr, "Unsupported parity\n");
+ return (0);
+ }
+
+ switch (stopbits) {
+ case 1:
+ options.c_cflag &= ~CSTOPB;
+ break;
+ case 2:
+ options.c_cflag |= CSTOPB;
+ break;
+ default:
+ fprintf (stderr, "Unsupported stop bits\n");
+ return (0);
+ }
+ /* Set input parity option */
+ if (parity != 'n')
+ options.c_iflag |= INPCK;
+ tcflush (fd, TCIFLUSH);
+ options.c_cc[VTIME] = 150;
+ options.c_cc[VMIN] = 0; /* Update the options and do it NOW */
+ //qd to set raw mode, which is copied from web
+ options.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP
+ | INLCR | IGNCR | ICRNL | IXON);
+ options.c_oflag &= ~OPOST;
+ options.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);
+ options.c_cflag &= ~(CSIZE | PARENB);
+ options.c_cflag |= CS8;
+
+ if (tcsetattr (fd, TCSANOW, &options) != 0) {
+ perror ("SetupSerial 3");
+ return (0);
+ }
+ return (1);
}
int CSerialPort::setup_serial()
{
- set_speed(mFd, 115200);
- set_Parity(mFd, 8, 1, 'N');
- return 0;
+ set_speed(mFd, 115200);
+ set_Parity(mFd, 8, 1, 'N');
+ return 0;
}
int CSerialPort::set_opt(int speed, int db, int sb, char pb, int overtime, bool raw_mode)
{
- int i = 0;
- struct termios old_cfg, new_cfg;
- if (mFd <= 0) {
- LOGE("not open dev, when set opt");
- return -1;
- }
- //first get it
- if (tcgetattr(mFd, &old_cfg) != 0) {
- LOGE("get serial attr error mFd = %d(%s)!\n", mFd, strerror(errno));
- return -1;
- }
-
- //set speed
- for (i = 0; i < sizeof(speed_arr) / sizeof(int); i++) {
- if (speed == name_arr[i]) {
- cfsetispeed(&new_cfg, speed_arr[i]);
- cfsetospeed(&new_cfg, speed_arr[i]);
- break;
- }
- }
-
- setdatabits(&new_cfg, db);
- setstopbits(&new_cfg, sb);
- setparity(&new_cfg, pb);
-
-
- if (overtime >= 0) {
- new_cfg.c_cc[VTIME] = overtime / 100; /* 设置超时 seconds*/
- new_cfg.c_cc[VMIN] = 0; /* Update the options and do it NOW */
- }
-
- if (raw_mode) {
- cfmakeraw(&new_cfg);
- }
-
- //clear
- tcflush(mFd, TCIOFLUSH);
- if (tcsetattr(mFd, TCSANOW, &new_cfg) < 0) {
- LOGE("%s, set serial attr error(%s)!\n", "TV", strerror(errno));
- return -1;
- }
- //clear,let be avail
- tcflush(mFd, TCIOFLUSH);
-
- return 0;
+ int i = 0;
+ struct termios old_cfg, new_cfg;
+ if (mFd <= 0) {
+ LOGE("not open dev, when set opt");
+ return -1;
+ }
+ //first get it
+ if (tcgetattr(mFd, &old_cfg) != 0) {
+ LOGE("get serial attr error mFd = %d(%s)!\n", mFd, strerror(errno));
+ return -1;
+ }
+
+ //set speed
+ for (i = 0; i < sizeof(speed_arr) / sizeof(int); i++) {
+ if (speed == name_arr[i]) {
+ cfsetispeed(&new_cfg, speed_arr[i]);
+ cfsetospeed(&new_cfg, speed_arr[i]);
+ break;
+ }
+ }
+
+ setdatabits(&new_cfg, db);
+ setstopbits(&new_cfg, sb);
+ setparity(&new_cfg, pb);
+
+
+ if (overtime >= 0) {
+ new_cfg.c_cc[VTIME] = overtime / 100; /* 设置超时 seconds*/
+ new_cfg.c_cc[VMIN] = 0; /* Update the options and do it NOW */
+ }
+
+ if (raw_mode) {
+ cfmakeraw(&new_cfg);
+ }
+
+ //clear
+ tcflush(mFd, TCIOFLUSH);
+ if (tcsetattr(mFd, TCSANOW, &new_cfg) < 0) {
+ LOGE("%s, set serial attr error(%s)!\n", "TV", strerror(errno));
+ return -1;
+ }
+ //clear,let be avail
+ tcflush(mFd, TCIOFLUSH);
+
+ return 0;
}
int CSerialPort::writeFile(const unsigned char *pData, unsigned int uLen)
{
- unsigned int len;
- len = write(mFd, pData, uLen);
- if (len == uLen) {
- return len;
- } else {
- tcflush(mFd, TCOFLUSH);
- LOGE("write data failed and tcflush hComm\n");
- return -1;
- }
+ unsigned int len;
+ len = write(mFd, pData, uLen);
+ if (len == uLen) {
+ return len;
+ } else {
+ tcflush(mFd, TCOFLUSH);
+ LOGE("write data failed and tcflush hComm\n");
+ return -1;
+ }
}
static int com_read_data(int hComm, unsigned char *pData, unsigned int uLen)
{
- char inbuff[uLen];
- char buff[uLen];
- char tempbuff[uLen];
- int i = 0, j = 0;
-
- memset(inbuff, '\0', uLen);
- memset(buff, '\0', uLen);
- memset(tempbuff, '\0', uLen);
-
- if (hComm < 0) {
- return -1;
- }
-
- char *p = inbuff;
-
- fd_set readset;
- struct timeval tv;
- int MaxFd = 0;
-
- unsigned int c = 0;
- int z, k;
-
- do {
- FD_ZERO(&readset);
- FD_SET(hComm, &readset);
- MaxFd = hComm + 1;
- tv.tv_sec = 0;
- tv.tv_usec = 100000;
- do {
- z = select(MaxFd, &readset, 0, 0, &tv);
- } while (z == -1 && errno == EINTR);
-
- if (z == -1) {
- hComm = -1;
- break;
- }
-
- if (z == 0) {
- hComm = -1;
- break;
- }
-
- if (FD_ISSET(hComm, &readset)) {
- z = read(hComm, buff, uLen - c);
+ char inbuff[uLen];
+ char buff[uLen];
+ char tempbuff[uLen];
+ int i = 0, j = 0;
+
+ memset(inbuff, '\0', uLen);
+ memset(buff, '\0', uLen);
+ memset(tempbuff, '\0', uLen);
+
+ if (hComm < 0) {
+ return -1;
+ }
+
+ char *p = inbuff;
+
+ fd_set readset;
+ struct timeval tv;
+ int MaxFd = 0;
+
+ unsigned int c = 0;
+ int z, k;
+
+ do {
+ FD_ZERO(&readset);
+ FD_SET(hComm, &readset);
+ MaxFd = hComm + 1;
+ tv.tv_sec = 0;
+ tv.tv_usec = 100000;
+ do {
+ z = select(MaxFd, &readset, 0, 0, &tv);
+ } while (z == -1 && errno == EINTR);
+
+ if (z == -1) {
+ hComm = -1;
+ break;
+ }
+
+ if (z == 0) {
+ hComm = -1;
+ break;
+ }
+
+ if (FD_ISSET(hComm, &readset)) {
+ z = read(hComm, buff, uLen - c);
#if 0
- for (k = 0; k < z; k++) {
- LOGD("%s, inbuff[%d]:%02X", "TV", k, buff[k]);
- }
+ for (k = 0; k < z; k++) {
+ LOGD("%s, inbuff[%d]:%02X", "TV", k, buff[k]);
+ }
#endif
- c += z;
-
- if (z > 0) {
- if (z < (signed int) uLen) {
- buff[z + 1] = '\0';
- memcpy(p, buff, z);
- p += z;
- } else {
- memcpy(inbuff, buff, z);
- }
-
- memset(buff, '\0', uLen);
- } else {
- hComm = -1;
- }
-
- if (c >= uLen) {
- hComm = -1;
- break;
- }
- }
- } while (hComm >= 0);
-
- memcpy(pData, inbuff, c);
- p = NULL;
- return c;
+ c += z;
+
+ if (z > 0) {
+ if (z < (signed int) uLen) {
+ buff[z + 1] = '\0';
+ memcpy(p, buff, z);
+ p += z;
+ } else {
+ memcpy(inbuff, buff, z);
+ }
+
+ memset(buff, '\0', uLen);
+ } else {
+ hComm = -1;
+ }
+
+ if (c >= uLen) {
+ hComm = -1;
+ break;
+ }
+ }
+ } while (hComm >= 0);
+
+ memcpy(pData, inbuff, c);
+ p = NULL;
+ return c;
}
int CSerialPort::readFile(unsigned char *pBuf, unsigned int uLen)
{
- //using non-block mode
- return com_read_data(mFd, pBuf, uLen);
+ //using non-block mode
+ return com_read_data(mFd, pBuf, uLen);
}
int CSerialPort::setdatabits(struct termios *s, int db)
{
- if (db == 5) {
- s->c_cflag = (s->c_cflag & ~CSIZE) | (CS5 & CSIZE);
- } else if (db == 6) {
- s->c_cflag = (s->c_cflag & ~CSIZE) | (CS6 & CSIZE);
- } else if (db == 7) {
- s->c_cflag = (s->c_cflag & ~CSIZE) | (CS7 & CSIZE);
- } else if (db == 8) {
- s->c_cflag = (s->c_cflag & ~CSIZE) | (CS8 & CSIZE);
- } else {
- LOGE("Unsupported data size!\n");
- }
- return 0;
+ if (db == 5) {
+ s->c_cflag = (s->c_cflag & ~CSIZE) | (CS5 & CSIZE);
+ } else if (db == 6) {
+ s->c_cflag = (s->c_cflag & ~CSIZE) | (CS6 & CSIZE);
+ } else if (db == 7) {
+ s->c_cflag = (s->c_cflag & ~CSIZE) | (CS7 & CSIZE);
+ } else if (db == 8) {
+ s->c_cflag = (s->c_cflag & ~CSIZE) | (CS8 & CSIZE);
+ } else {
+ LOGE("Unsupported data size!\n");
+ }
+ return 0;
}
int CSerialPort::setstopbits(struct termios *s, int sb)
{
- if (sb == 1) {
- s->c_cflag &= ~CSTOPB;
- } else if (sb == 2) {
- s->c_cflag |= CSTOPB;
- } else {
- LOGE("Unsupported stop bits!\n");
- }
- return 0;
+ if (sb == 1) {
+ s->c_cflag &= ~CSTOPB;
+ } else if (sb == 2) {
+ s->c_cflag |= CSTOPB;
+ } else {
+ LOGE("Unsupported stop bits!\n");
+ }
+ return 0;
}
int CSerialPort::setparity(struct termios *s, char pb)
{
- if (pb == 'n' || pb == 'N') {
- s->c_cflag &= ~PARENB; /* Clear parity enable */
- s->c_cflag &= ~INPCK; /* Enable parity checking */
- } else if (pb == 'o' || pb == 'O') {
- s->c_cflag |= (PARODD | PARENB);
- s->c_cflag |= INPCK; /* Disable parity checking */
- } else if (pb == 'e' || pb == 'E') {
- s->c_cflag |= PARENB; /* Enable parity */
- s->c_cflag &= ~PARODD;
- s->c_iflag |= INPCK; /* Disable parity checking */
- } else if (pb == 's' || pb == 'S') {
- s->c_cflag &= ~PARENB;
- s->c_cflag &= ~CSTOPB;
- s->c_cflag |= INPCK; /* Disable parity checking */
- } else {
- LOGE("Unsupported parity!\n");
- }
- return 0;
+ if (pb == 'n' || pb == 'N') {
+ s->c_cflag &= ~PARENB; /* Clear parity enable */
+ s->c_cflag &= ~INPCK; /* Enable parity checking */
+ } else if (pb == 'o' || pb == 'O') {
+ s->c_cflag |= (PARODD | PARENB);
+ s->c_cflag |= INPCK; /* Disable parity checking */
+ } else if (pb == 'e' || pb == 'E') {
+ s->c_cflag |= PARENB; /* Enable parity */
+ s->c_cflag &= ~PARODD;
+ s->c_iflag |= INPCK; /* Disable parity checking */
+ } else if (pb == 's' || pb == 'S') {
+ s->c_cflag &= ~PARENB;
+ s->c_cflag &= ~CSTOPB;
+ s->c_cflag |= INPCK; /* Disable parity checking */
+ } else {
+ LOGE("Unsupported parity!\n");
+ }
+ return 0;
}