2#include <spdlog/spdlog.h>
8class MockCommInterface;
47 template <
typename StreamT>
62 virtual std::string
sendCommand(
const std::string& command) = 0;
100 std::string
stripEcho(
const std::string& response,
const std::string& command);
Abstract interface for communicating with a scanner.
Definition ICommInterface.hpp:45
friend class MockCommInterface
Definition ICommInterface.hpp:50
virtual ~ICommInterface()=default
CommFormat commFormat
Active framing format.
Definition ICommInterface.hpp:109
void setCommFormat(CommFormat format)
Set the communication framing format.
std::string inTermStr
Expected response terminator string.
Definition ICommInterface.hpp:110
std::string stripEcho(const std::string &response, const std::string &command)
Strip a command echo from the start of a response.
virtual std::string describe() const =0
Return a human-readable description of this interface.
CommFormat getCommFormat()
Get the current communication framing format.
Definition ICommInterface.hpp:91
friend class AsioInterface
Definition ICommInterface.hpp:48
std::string addHeaderAndTerminator(const std::string &command)
Wrap a command string with the appropriate header and terminator.
virtual std::string sendCommand(const std::string &command)=0
Send a command and return the response (thread-safe).
virtual std::string sendCommandUnlocked(const std::string &command)=0
Send a command and return the response without locking.
std::mutex commMutex
Mutex to ensure thread-safe access to the communixcation interface.
Definition ICommInterface.hpp:114
Definition AsioInterface.hpp:5
CommFormat
Communication framing format for command/response exchange.
Definition ICommInterface.hpp:33
@ STX_HEADER_ETX_IN_ETX_OUT
STX header with ETX terminator.
Definition ICommInterface.hpp:36
@ NO_HEADER_CRLF_IN_CR_OUT
No header; CR+LF in, CR out.
Definition ICommInterface.hpp:35
@ NO_HEADER_CR_IN_CR_OUT
No header; CR terminator in both directions.
Definition ICommInterface.hpp:34
ErrCode
Error codes returned by the scanner in "ER,CMD,code" responses.
Definition ICommInterface.hpp:13
@ AREA_SPECIFICATION_DATA_INCORRECT
Area specification data is incorrect.
Definition ICommInterface.hpp:21
@ PARAM2_IN_HEX_BUT_OUT_OF_RANGE
Parameter 2 is hex but out of range.
Definition ICommInterface.hpp:19
@ FILE_DOES_NOT_EXIST
Specified file does not exist.
Definition ICommInterface.hpp:22
@ DEVICE_FAULT
Device fault; contact KEYENCE support.
Definition ICommInterface.hpp:29
@ PARAM2_NOT_IN_HEX
Parameter 2 is not in hexadecimal.
Definition ICommInterface.hpp:18
@ CMD_UNDEFINED
Undefined command received.
Definition ICommInterface.hpp:14
@ TWO_OR_MORE_MARKS_IN_PRESET_DATA
Preset data contains two or more "!" marks.
Definition ICommInterface.hpp:20
@ COMMAND_NOT_EXECUTABLE_IN_CURRENT_STATUS
Command not executable in current status.
Definition ICommInterface.hpp:25
@ MISMATCHED_CMD_FMT
Mismatched command format (invalid parameter count).
Definition ICommInterface.hpp:15
@ PARAM1_OUT_OF_RANGE
Parameter 1 value exceeds the set range.
Definition ICommInterface.hpp:16
@ TMM_LON_MM_OUT_OF_RANGE
TMM-LON mm value out of range.
Definition ICommInterface.hpp:23
@ TMM_KEYENCE_COMMUNICATION_CANNOT_BE_CHECKED
TMM-KEYENCE communication check failed.
Definition ICommInterface.hpp:24
@ PARAM2_OUT_OF_RANGE
Parameter 2 value exceeds the set range.
Definition ICommInterface.hpp:17
@ CONNECTED_TO_AUTOID_NETWORK_NAVIGATOR
Connected to AutoID Network Navigator.
Definition ICommInterface.hpp:28
@ BUFFER_OVERFLOW
Buffer overflow; commands cannot execute.
Definition ICommInterface.hpp:26
@ PARAMETER_LOAD_OR_SAVE_ERROR
Parameter load/save error.
Definition ICommInterface.hpp:27