54 if ((
size_t)pHandle >= s->
devices.size())
68 if ((
size_t)pHandle >= s->
devices.size())
89 if ((
size_t)pHandle > s->
devices.size())
107 switch (data->
hdr.
id)
115 static time_t nextGpsMessageTime;
116 time_t currentTime = time(
NULLPTR);
117 if (currentTime > nextGpsMessageTime)
119 nextGpsMessageTime = currentTime + 5;
227 map<int, vector<p_data_t>> packets;
234 cMutexLocker logMutexLocker(&inertialSense->
m_logMutex);
237 packets[i->first] = i->second;
250 for (
map<
int, vector<p_data_t>>::iterator i = packets.begin(); i != packets.end(); i++)
252 for (
size_t j = 0; j < i->second.size(); j++)
254 if (!inertialSense->
m_logger.
LogData(i->first, &i->second[j].hdr, i->second[j].buf))
269 printf(
"\n...Logger thread terminated...\n");
278 vec.push_back(*data);
285 if (port[0] ==
'0' && port[1] ==
'\0')
304 float maxDiskSpacePercent,
305 uint32_t maxFileSize,
306 const string& subFolder)
320 return EnableLogging(path, logType, maxDiskSpacePercent, maxFileSize, subFolder);
333 vector<string> pieces;
335 if (pieces.size() < 3)
340 if (pieces[1] ==
"SERIAL")
342 if (pieces.size() < 4)
346 else if ((opened = (
m_serialServer.
Open(pieces[2].c_str(), atoi(pieces[3].c_str())))))
354 string url = (pieces.size() > 3 ? pieces[3] :
"");
355 string userAgent =
"NTRIP Inertial Sense";
356 string username = (pieces.size() > 4 ? pieces[4] :
"");
357 string password = (pieces.size() > 5 ? pieces[5] :
"");
399 size_t colon = ipAndPort.find(
':', 0);
400 if (colon == string::npos)
405 string host = ipAndPort.substr(0, colon);
406 string portString = ipAndPort.substr(colon + 1);
407 int port = (int)strtol(portString.c_str(),
NULLPTR, 10);
434 cout << endl <<
"Failed to write bytes to tcp server!" << endl;
447 static int error = 0;
451 #if 0 // Read one byte (simple method) 460 #else // Read a set of bytes (fast method) 492 printf(
"PARSE ERROR: %d\n", error++);
559 vector<string> ports;
644 if (periodMultiple < 0)
675 return BootloadFile(comPort, fileName,
"", baudRate, uploadProgress, verifyProgress,
NULLPTR, updateBootloader);
680 vector<bootloader_result_t> results;
681 vector<string> portStrings;
682 vector<bootloader_state_t> state;
692 sort(portStrings.begin(), portStrings.end());
693 state.resize(portStrings.size());
697 ifstream tmpStream(fileName);
698 if (!tmpStream.good())
700 for (
size_t i = 0; i < state.size(); i++)
702 results.push_back({ state[i].serial.port,
"File does not exist" });
707 if (results.size() == 0)
710 for (
size_t i = 0; i < state.size(); i++)
715 state[i].param.uploadProgress = uploadProgress;
716 state[i].param.verifyProgress = verifyProgress;
717 state[i].param.statusText = infoProgress;
718 state[i].param.fileName = fileName.c_str();
719 state[i].param.bootName = bootloaderFileName.c_str();
720 state[i].param.port = &state[i].serial;
721 state[i].param.verifyFileName =
NULLPTR;
722 state[i].param.flags.bitFields.enableVerify = (verifyProgress !=
NULLPTR);
723 state[i].param.numberOfDevices = (int)state.size();
724 state[i].param.baudRate = baudRate;
725 if (strstr(state[i].
param.fileName,
"EVB") !=
NULL)
727 strncpy(state[i].
param.bootloadEnableCmd,
"EBLE", 4);
731 strncpy(state[i].
param.bootloadEnableCmd,
"BLEN", 4);
734 if (updateBootloader)
745 for (
size_t i = 0; i < state.size(); i++)
751 for (
size_t i = 0; i < state.size(); i++)
753 results.push_back({ state[i].serial.port, state[i].param.error });
775 cout << endl <<
"Client connecting..." << endl;
780 cout << endl <<
"Client connected: " << (int)socket << endl;
785 cout << endl <<
"Client connection failed!" << endl;
790 cout << endl <<
"Client disconnected: " << (int)socket << endl;
803 vector<string> ports;
804 size_t maxCount = UINT32_MAX;
812 maxCount = atoi(port + 1);
813 maxCount = (maxCount == 0 ? UINT32_MAX : maxCount);
823 for (
size_t i = 0; i < ports.size(); i++)
848 #define NUM_ENSURED_PKTS 10 852 if (
comManagerInit((
int)
m_comManagerState.
devices.size(),
NUM_ENSURED_PKTS, 10, 10,
staticReadPacket,
staticSendPacket, 0,
staticProcessRxData, 0, 0, &
m_cmInit,
m_cmPorts) == -1)
859 time_t startTime = time(0);
877 bool removedSerials =
false;
885 removedSerials =
true;
900 removedSerials =
true;
906 comManagerInit((
int)
m_comManagerState.
devices.size(), 10, 10, 10,
staticReadPacket,
staticSendPacket, 0,
staticProcessRxData, 0, 0, &
m_cmInit,
m_cmPorts);
int comManagerDisableData(int pHandle, uint32_t dataId)
static void LoggerThread(void *info)
void RemoveDevice(size_t index)
bool OnPacketReceived(const uint8_t *data, uint32_t dataLength)
void StopBroadcasts(bool allPorts=true)
vector< string > GetPorts()
static vector< bootloader_result_t > BootloadFile(const string &comPort, const string &fileName, const string &bootloaderFileName, int baudRate=IS_BAUD_RATE_BOOTLOADER, pfnBootloadProgress uploadProgress=NULLPTR, pfnBootloadProgress verifyProgress=NULLPTR, pfnBootloadStatus infoProgress=NULLPTR, bool updateBootloader=false)
int comManagerSendRawData(int pHandle, uint32_t dataId, void *dataPtr, int dataSize, int dataOffset)
static void StepLogger(InertialSense *i, const p_data_t *data, int pHandle)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val)
is_comm_instance_t m_gpComm
NMI_API SOCKET socket(uint16 u16Domain, uint8 u8Type, uint8 u8Flags)
void threadJoinAndFree(void *handle)
int comManagerValidateBaudRate(unsigned int baudRate)
int serialPortReadTimeout(serial_port_t *serialPort, unsigned char *buffer, int readCount, int timeoutMilliseconds)
bool HasReceivedResponseFromDevice(size_t index)
std::function< void(InertialSense *i, p_data_t *data, int pHandle)> pfnHandleBinaryData
int serialPortOpen(serial_port_t *serialPort, const char *port, int baudRate, int blocking)
ensured_pkt_t * ensuredPackets
#define PID_STOP_BROADCASTS_ALL_PORTS
InertialSense(pfnHandleBinaryData callback=NULL)
uint64_t m_clientServerByteCount
void * threadCreateAndStart(void(*function)(void *info), void *info)
uint8_t m_gpCommBuffer[PKT_BUF_SIZE]
broadcast_msg_t * broadcastMsg
bool OpenServerConnection(const string &connectionString)
size_t splitString(const string &s, const string &delimiter, vector< string > &result)
size_t count(InputIterator first, InputIterator last, T const &item)
pfnHandleBinaryData binaryCallbackGlobal
void serialPortSetPort(serial_port_t *serialPort, const char *port)
static void GetComPorts(vector< string > &ports)
protocol_type_t is_comm_parse_byte(is_comm_instance_t *instance, uint8_t byte)
int Open(const string &ipAddress, int port)
int m_clientBufferBytesToSend
void CloseServerConnection()
static void staticProcessRxData(CMHANDLE cmHandle, int pHandle, p_data_t *data)
void OnClientConnecting(cISTcpServer *server) OVERRIDE
void comManagerStep(void)
void SetEvbFlashConfig(const evb_flash_cfg_t &evbFlashCfg, int pHandle=0)
bool CreateHost(const string &ipAndPort)
#define COM_MANAGER_BUF_SIZE_BCAST_MSG(max_num_bcast_msgs)
static int staticReadPacket(CMHANDLE cmHandle, int pHandle, unsigned char *buf, int len)
void EnableLogging(bool enabled)
bool LogData(unsigned int device, p_data_hdr_t *dataHdr, const uint8_t *dataBuf)
char port[MAX_SERIAL_PORT_NAME_LENGTH+1]
int Open(const string &host, int port, int timeoutMilliseconds=IS_SOCKET_DEFAULT_TIMEOUT_MS)
void SendData(eDataIDs dataId, uint8_t *data, uint32_t length, uint32_t offset)
#define PID_STOP_BROADCASTS_CURRENT_PORT
bool SetLoggerEnabled(bool enable, const string &path=cISLogger::g_emptyString, cISLogger::eLogType logType=cISLogger::eLogType::LOGTYPE_DAT, uint64_t rmcPreset=RMC_PRESET_PPD_BITS, float maxDiskSpacePercent=0.5f, uint32_t maxFileSize=1024 *1024 *5, const string &subFolder=cISLogger::g_emptyString)
void SendRawData(eDataIDs dataId, uint8_t *data, uint32_t length=0, uint32_t offset=0)
bool InitSaveTimestamp(const string &timeStamp, const string &directory=g_emptyString, const string &subDirectory=g_emptyString, int numDevices=1, eLogType logType=LOGTYPE_DAT, float maxDiskSpacePercent=0.5f, uint32_t maxFileSize=1024 *1024 *5, bool useSubFolderTimestamp=true)
int is_comm_free(is_comm_instance_t *instance)
int Write(const uint8_t *data, int dataLength)
void SetFlashConfig(const nvm_flash_cfg_t &flashConfig, int pHandle=0)
com_manager_port_t * m_cmPorts
int enableBootloader(serial_port_t *port, int baudRate, char *error, int errorLength, const char *bootloadEnableCmd)
int serialPortClose(serial_port_t *serialPort)
bool EnableLogging(const string &path, cISLogger::eLogType logType, float maxDiskSpacePercent, uint32_t maxFileSize, const string &subFolder)
uint32_t broadcastMsgSize
static int staticSendPacket(CMHANDLE cmHandle, int pHandle, unsigned char *buf, int len)
int serialPortWrite(serial_port_t *serialPort, const unsigned char *buffer, int writeCount)
int(* pfnBootloadProgress)(const void *obj, float percent)
bool m_disableBroadcastsOnClose
void OnClientDisconnected(cISTcpServer *server, socket_t socket) OVERRIDE
int gpsToNmeaGGA(const gps_pos_t *gps, char *buffer, int bufferLength)
USBInterfaceDescriptor data
bool BroadcastBinaryData(uint32_t dataId, int periodMultiple, pfnHandleBinaryData callback=NULL)
bool OpenSerialPorts(const char *port, int baudRate)
int bootloadFileEx(bootload_params_t *params)
static void bootloaderUpdateBootloaderThread(void *state)
static void bootloaderThread(void *state)
void comManagerAssignUserPointer(CMHANDLE cmInstance, void *userPointer)
void SetSysCmd(const system_command_t &sysCmd, int pHandle=0)
void is_comm_init(is_comm_instance_t *instance, uint8_t *buffer, int bufferSize)
#define DID_EVB_FLASH_CFG
char error[BOOTLOADER_ERROR_LENGTH]
#define COM_MANAGER_BUF_SIZE_ENSURED_PKTS(max_num_ensured_pkts)
#define MAX_NUM_BCAST_MSGS
bool Open(const char *port, int baudRate=IS_COM_BAUDRATE_DEFAULT, bool disableBroadcastsOnClose=false)
cISStream * m_clientStream
pfnHandleBinaryData binaryCallback[256]
InertialSense::com_manager_cpp_state_t m_comManagerState
int bootloadUpdateBootloaderEx(bootload_params_t *p)
GeneratorWrapper< T > map(Func &&function, GeneratorWrapper< U > &&generator)
InertialSense * inertialSenseInterface
vector< is_device_t > devices
void comManagerGetDataRmc(int pHandle, uint64_t rmcBits, uint32_t rmcOptions)
int comManagerSend(int pHandle, uint8_t pktInfo, bufPtr_t *bodyHdr, bufPtr_t *txData, uint8_t pFlags)
void * comManagerGetUserPointer(CMHANDLE cmInstance)
static const string g_emptyString
bool SetDeviceInfo(const dev_info_t *info, unsigned int device=0)
virtual int Read(void *buffer, int count)
int comManagerSendData(int pHandle, uint32_t dataId, void *dataPtr, int dataSize, int dataOffset)
void(* pfnBootloadStatus)(const void *obj, const char *infoString)
bool HasReceivedResponseFromAllDevices()
protocol_type_t is_comm_parse(is_comm_instance_t *instance)
char bootloadEnableCmd[16]
void comManagerGetData(int pHandle, uint32_t dataId, int offset, int size, int periodMultiple)
Request data This function requests the specified data w/ offset and length for partial reads...
uint8_t buf[MAX_DATASET_SIZE]
int comManagerInit(int numHandles, int maxEnsuredPackets, int stepPeriodMilliseconds, int retryCount, pfnComManagerRead readFnc, pfnComManagerSend sendFnc, pfnComManagerSendBufferAvailableBytes txFreeFnc, pfnComManagerPostRead pstRxFnc, pfnComManagerPostAck pstAckFnc, pfnComManagerDisableBroadcasts disableBcastFnc, com_manager_init_t *buffers, com_manager_port_t *cmPorts)
com_manager_init_t m_cmInit
bool Open(const std::string &portName, int baudRate=BAUDRATE_921600, int timeout=0, bool blocking=false)
#define BOOTLOADER_ERROR_LENGTH
virtual int Write(const void *buffer, int count)
int serialPortIsOpen(serial_port_t *serialPort)
map< int, vector< p_data_t > > m_logPackets
cISSerialPort m_serialServer
uint32_t ensuredPacketsSize
void HttpGet(const string &subUrl, const string &userAgent, const string &userName, const string &password)
void OnClientConnectFailed(cISTcpServer *server) OVERRIDE
void OnClientConnected(cISTcpServer *server, socket_t socket) OVERRIDE
CMHANDLE comManagerGetGlobal(void)
void BroadcastBinaryDataRmcPreset(uint64_t rmcPreset=RMC_PRESET_INS_BITS, uint32_t rmcOptions=0)
pfnStepLogFunction stepLogFunction