Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
Language: Cpp
# BasedOnStyle: Microsoft
AccessModifierOffset: -2
AlignAfterOpenBracket: BlockIndent
AlignAfterOpenBracket: Align
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments: false
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
Expand All @@ -24,8 +22,8 @@ AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: false
BinPackParameters: AlwaysOnePerLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/error_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ extern "C"
{
#endif

using ErrorCallbackT = void (*)(
int error_code,
const char *message
);
using ErrorCallbackT = void (*)(int error_code, const char *message);

#ifdef __cplusplus
} // extern "C"
Expand Down
14 changes: 7 additions & 7 deletions include/cpp_core/interface/get_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ extern "C"
{
struct Version
{
int major = version::MAJOR;
int minor = version::MINOR;
int patch = version::PATCH;
int major = version::MAJOR;
int minor = version::MINOR;
int patch = version::PATCH;
const char *commit_hash_short = version::GIT_COMMIT_HASH_SHORT;
const char *commit_hash_full = version::GIT_COMMIT_HASH_FULL;
const char *commit_date = version::GIT_COMMIT_DATE;
const char *branch = version::GIT_BRANCH;
const char *version_string = version::VERSION;
const char *commit_hash_full = version::GIT_COMMIT_HASH_FULL;
const char *commit_date = version::GIT_COMMIT_DATE;
const char *branch = version::GIT_BRANCH;
const char *version_string = version::VERSION;
};
} // namespace cpp_core

Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_abort_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return 0 on success or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialAbortRead(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialAbortRead(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_abort_write.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return 0 on success or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialAbortWrite(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialAbortWrite(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_clear_buffer_in.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return 0 on success or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialClearBufferIn(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialClearBufferIn(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_clear_buffer_out.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return 0 on success or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialClearBufferOut(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialClearBufferOut(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_close.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return 0 on success or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialClose(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialClose(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_drain.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return 0 on success or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialDrain(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialDrain(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_in_bytes_total.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Total number of bytes read or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialInBytesTotal(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int64_t;
MODULE_API auto serialInBytesTotal(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int64_t;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_in_bytes_waiting.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Bytes available for instant reading or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialInBytesWaiting(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialInBytesWaiting(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
18 changes: 5 additions & 13 deletions include/cpp_core/interface/serial_list_ports.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,11 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Number of ports found or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialListPorts(
void (*callback_fn)(
const char *port,
const char *path,
const char *manufacturer,
const char *serial_number,
const char *pnp_id,
const char *location_id,
const char *product_id,
const char *vendor_id
),
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialListPorts(void (*callback_fn)(const char *port, const char *path, const char *manufacturer,
const char *serial_number, const char *pnp_id,
const char *location_id, const char *product_id,
const char *vendor_id),
ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
10 changes: 2 additions & 8 deletions include/cpp_core/interface/serial_open.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return A positive opaque handle on success or a negative value from ::cpp_core::StatusCodes on failure.
*/
MODULE_API auto serialOpen(
void *port,
int baudrate,
int data_bits,
int parity = 0,
int stop_bits = 0,
ErrorCallbackT error_callback = nullptr
) -> intptr_t;
MODULE_API auto serialOpen(void *port, int baudrate, int data_bits, int parity = 0, int stop_bits = 0,
ErrorCallbackT error_callback = nullptr) -> intptr_t;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_out_bytes_total.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Total number of bytes written or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialOutBytesTotal(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int64_t;
MODULE_API auto serialOutBytesTotal(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int64_t;

#ifdef __cplusplus
}
Expand Down
5 changes: 1 addition & 4 deletions include/cpp_core/interface/serial_out_bytes_waiting.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Bytes still waiting in the TX FIFO or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialOutBytesWaiting(
int64_t handle,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialOutBytesWaiting(int64_t handle, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
10 changes: 2 additions & 8 deletions include/cpp_core/interface/serial_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Bytes read (0 on timeout) or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialRead(
int64_t handle,
void *buffer,
int buffer_size,
int timeout_ms,
int multiplier,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialRead(int64_t handle, void *buffer, int buffer_size, int timeout_ms, int multiplier,
ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
10 changes: 2 additions & 8 deletions include/cpp_core/interface/serial_read_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Bytes read (0 on timeout) or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialReadLine(
int64_t handle,
void *buffer,
int buffer_size,
int timeout_ms,
int multiplier,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialReadLine(int64_t handle, void *buffer, int buffer_size, int timeout_ms, int multiplier,
ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
11 changes: 2 additions & 9 deletions include/cpp_core/interface/serial_read_until.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,8 @@ extern "C"
* @return Bytes read (including the terminator), 0 on timeout or a negative error code from ::cpp_core::StatusCodes
* on error.
*/
MODULE_API auto serialReadUntil(
int64_t handle,
void *buffer,
int buffer_size,
int timeout_ms,
int multiplier,
void *until_char,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialReadUntil(int64_t handle, void *buffer, int buffer_size, int timeout_ms, int multiplier,
void *until_char, ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
12 changes: 3 additions & 9 deletions include/cpp_core/interface/serial_read_until_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Bytes read (including the terminator) or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialReadUntilSequence(
int64_t handle,
void *buffer,
int buffer_size,
int timeout_ms,
int multiplier,
void *sequence,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialReadUntilSequence(int64_t handle, void *buffer, int buffer_size, int timeout_ms,
int multiplier, void *sequence, ErrorCallbackT error_callback = nullptr)
-> int;

#ifdef __cplusplus
}
Expand Down
10 changes: 2 additions & 8 deletions include/cpp_core/interface/serial_write.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@ extern "C"
* @param error_callback [optional] Callback to invoke on error. Defined in error_callback.h. Default is `nullptr`.
* @return Bytes written (may be 0 on timeout) or a negative error code from ::cpp_core::StatusCodes on error.
*/
MODULE_API auto serialWrite(
int64_t handle,
const void *buffer,
int buffer_size,
int timeout_ms,
int multiplier,
ErrorCallbackT error_callback = nullptr
) -> int;
MODULE_API auto serialWrite(int64_t handle, const void *buffer, int buffer_size, int timeout_ms, int multiplier,
ErrorCallbackT error_callback = nullptr) -> int;

#ifdef __cplusplus
}
Expand Down
26 changes: 13 additions & 13 deletions include/cpp_core/status_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ namespace cpp_core
{
enum class StatusCodes
{
kSuccess = 0,
kCloseHandleError = -1,
kInvalidHandleError = -2,
kReadError = -3,
kWriteError = -4,
kGetStateError = -5,
kSetStateError = -6,
kSetTimeoutError = -7,
kBufferError = -8,
kNotFoundError = -9,
kClearBufferInError = -10,
kSuccess = 0,
kCloseHandleError = -1,
kInvalidHandleError = -2,
kReadError = -3,
kWriteError = -4,
kGetStateError = -5,
kSetStateError = -6,
kSetTimeoutError = -7,
kBufferError = -8,
kNotFoundError = -9,
kClearBufferInError = -10,
kClearBufferOutError = -11,
kAbortReadError = -12,
kAbortWriteError = -13,
kAbortReadError = -12,
kAbortWriteError = -13,
};
} // namespace cpp_core