You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TermApp/app/src/main/cpp/SensorPort.cpp

53 lines
881 B
C++

#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <jni.h>
#include "SerialPort.h"
#include "android/log.h"
#ifdef DEPENDING_GPIO
#include "GPIOControl.h"
#endif
namespace ns_sp
{
SensorPort::SensorPort(const SERIAL_PARAM& serialParam) : m_devparam(serialParam)
{
memset(&serialport, 0, sizeof(SIO_PARAM_SERIAL_DEF));
}
bool SensorPort::Startup()
{
bool res = Open(m_devparam.pathname, m_devparam.baudrate, m_devparam.stopbit, m_devparam.databit, m_devparam.parity, 0, 0);
if (!res)
{
return res;
}
std::vector<uint8_t> cmd;
res = MakeCmdData(cmd);
if (!res)
{
Close();
return res;
}
recv ();
OnRecvData(data, dataLength);
return res;
}
}