Binary tcm protocol c++ communication examples, 2 binary tcm protocol c++ communication examples, 1 commprotocol.h file – PNI TCM 5 User Manual
Page 47
PNI Sensor Corporation
Doc #1007537 r12
TCM3 & TCM5 User Manual
– Sept 2012
Page 47
4.4.2 Binary TCM Protocol C++ Communication Examples
The following 4 example files, CommProtocol.h, CommProtocol.cp, TCM5.h and TCM5.cp would be used
together for proper communication with a TCM3, TCM5 or TCM5L module.
NOTE: The follwing files are not included in the samples code: SystemSenPort.h; Processes.h,
TickGenerator.h.
4.4.2.1 CommProtocol.h File:
#pragma once
#include "SystemSerPort.h"
#include "Processes.h"
//
// This file contains objects used to handle the serial communication with the unit.
Unfortunately, these files are not available as the program was written on a non-PC computer.
The comments in the code should explain what is expected to be sent or received from these
functions so that you can write this section for your specific platform. For example, with the
TickGenerator.h, you would need to write a routing that generates 10msec ticks.
//
//
// CommHandler is a base class that provides a callback for incoming messages.
//
class
CommHandler
{
public
:
// Call back to be implemented in derived class.
virtual
void
HandleComm(UInt8 frameType,
void
* dataPtr =
NULL
, UInt16 dataLen =
0
) {}
};
//
// CommProtocol handles the actual serial communication with the unit.
// Process is a base class that provides CommProtocol with cooperative parallel processing. The
Control method will be
// called by a process manager on a continuous basis.
//
class
CommProtocol :
public
Process
{
public
:
enum
{