My Project
|
#include <stdint.h>
#include <stdio.h>
#include <stdbool.h>
Go to the source code of this file.
Classes | |
struct | tagCanMessage |
This structure contains all possible options for the configuration of a CAN message for transmitting by Cansim using 'Cansim::AddMessage'. Provides an alternative option to call the method 'Cansim::AddMessage' with all these arguments, but does same thing. After the method call the structure may be destroyed. More... | |
struct | tagRecvMsgCansim |
Macros | |
#define | DllExport __attribute__ ((visibility("default"))) |
Typedefs | |
typedef void * | CansimHandler |
typedef void(* | PrintFunc) (const char *) |
typedef enum LOG_LEVELS_CANSIM | LOG_LEVELS_CANSIM |
typedef struct tagCanMessage | CanMessage |
typedef struct tagCanMessage * | PtrCanMessage |
typedef struct tagRecvMsgCansim | RecvMsgCansim |
typedef struct tagRecvMsgCansim * | PtrRecvMsgCansim |
Enumerations | |
enum | LOG_LEVELS_CANSIM { ERROR_LEVEL_CANSIM , INFO_LEVEL_CANSIM , COMM_LEVEL_CANSIM } |
Functions | |
DllExport uint8_t | DLC2length (uint8_t *DLC) |
This method converts DLC to length according to: https://elearning.vector.com/mod/page/view.php?id=368. More... | |
DllExport CansimHandler | NewCansim (void) |
DllExport void | DeleteCansim (CansimHandler Handle) |
DllExport int32_t | ConnectCansim (CansimHandler Handle, const char *COMPort, const uint32_t ReadTimeout, const uint32_t WriteTimeout) |
Open serial connection to the CANSim4. More... | |
DllExport void | DisconnectCansim (CansimHandler Handle) |
Method to close Cansim's communication port. More... | |
DllExport int32_t | StartReceiverCansim (CansimHandler Handle) |
This method starts thread for receiving messages. Designed for receiving asynchronous messages. If you do not need to receive asynchronous messagess (methods: Cansim::RequestMessage, Cansim::RequestSignal) than there is not any benefit if started. NOTE: For terminating use: Cansim::StopReceiver. More... | |
DllExport void | StopReceiverCansim (CansimHandler Handle) |
Stop the receiver thread - check Cansim::StartReceiver. More... | |
DllExport void | DebugCommCansim (CansimHandler Handle, const char *FileName) |
DllExport int32_t | ResetCansim (CansimHandler Handle) |
Reset Cansim device. It means that all messages, signals, etc. will be removed even default messages, transmitting cansim version. And load predefined messages from a flash memory. More... | |
DllExport int32_t | RebootCansim (CansimHandler Handle, const bool Jump) |
This method cause Cansim reboot. Takes about 2 seconds. More... | |
DllExport int32_t | BootloaderCansim (CansimHandler Handle) |
Cansim bootloader (regime "F"). More... | |
DllExport int32_t | GetVersionCansim (CansimHandler Handle) |
Get the cansim firmware api version. More... | |
DllExport int32_t | AddMessageCansim (CansimHandler Handle, const PtrCanMessage Msg, const uint8_t *Data) |
This method add and configure CAN message to the cansim device to transmit. More... | |
DllExport int32_t | RemoveMessageCansim (CansimHandler Handle, const uint16_t MsgHandler) |
Removes message from Cansim,. More... | |
DllExport int32_t | EnableMessageCansim (CansimHandler Handle, const uint16_t MsgHandler) |
Enable message transmission to the CAN bus. More... | |
DllExport int32_t | DisableMessageCansim (CansimHandler Handle, const uint16_t MsgHandler) |
Disable message transmission to the CAN bus. More... | |
DllExport int32_t | SetMessageDataCansim (CansimHandler Handle, const uint16_t MsgHandler, const uint8_t *Data, const uint8_t *DataMask, const bool Async, const bool response) |
Set the CAN Message value. More... | |
DllExport int32_t | GetHandlerCansim (CansimHandler Handle, const uint8_t CanMap, const uint8_t CanGatewayNumber, const uint32_t CanID, const bool ExtendedCanID, const bool FastSlowSend, const bool FD) |
Get the specified message handler by Cansim request. More... | |
DllExport int32_t | EnableRequestCansim (CansimHandler Handle, const uint16_t ReqHandler) |
Enable message request. More... | |
DllExport int32_t | DisableRequestCansim (CansimHandler Handle, const uint16_t ReqHandler) |
Disable message request. More... | |
DllExport int32_t | RemoveRequestCansim (CansimHandler Handle, const uint16_t ReqHandler) |
Remove message request - does not freeing memory, but lowering cansim's CPU usage. More... | |
DllExport int32_t | RequestMessageCansim (CansimHandler Handle, const uint8_t CanMap, const uint32_t CanID, const bool Enabled, const bool ExtendedCanID, const uint8_t DLC, const bool CheckDLC, const bool ReturnID, const uint8_t *Mask) |
Method provide receiving specific CAN bus message to the serial line. Message register by this method is sent to the serial port asynchronously without request. More... | |
DllExport int32_t | RequestSignalCansim (CansimHandler Handle, const int32_t MsgHandler, const uint16_t StartSymbol, const uint16_t StopSymbol) |
This method gets a signal from a message specified by the requested message handler. Signal range is specified by start and stop symbol and must not exceed 16 bit. Difference StopSymbol - StartSymbol must not exceed 15.**. More... | |
DllExport int32_t | SignalReadValue32Cansim (CansimHandler Handle, const uint16_t SigHandler, uint32_t *Value, uint32_t *TimeFromReceive, bool GetLatest) |
This method reads cached 32 bit value of the signal registered by Cansim::RequestSignal. More... | |
DllExport int32_t | SignalReadValue64Cansim (CansimHandler Handle, const uint16_t SigHandler, uint64_t *Value, uint32_t *TimeFromReceive, bool GetLatest) |
This method reads cached 64 bit value of the signal registered by Cansim::RequestSignal. More... | |
DllExport int32_t | AddSignalCansim (CansimHandler Handle, const uint16_t MsgHandler, const uint8_t Group, const uint16_t StartSymbol, const uint16_t StopSymbol, const uint8_t MuxInfo) |
This method adds a signal to a message specified by handler. Signal range is specified by start and stop symbol and must not exceed 16 bit. It also allows add counter as a specific signal. Both StartSymbol and StoptSymbol symbols are included to the signal range. Difference StopSymbol - StartSymbol must not exceed 15. More... | |
DllExport int32_t | SignalChangeValueCansim (CansimHandler Handle, const uint16_t SigHandler, const uint16_t Value, const bool async, const bool response) |
Change value of signal specified by handler. More... | |
DllExport int32_t | BlobRemoveCansim (CansimHandler Handle) |
Remove blob from cansim memory. More... | |
DllExport int32_t | RemoveSignalCansim (CansimHandler Handle, const uint16_t SigHandler) |
Remove CAN signal specified by its handler. It does not freeing a memory but lowering Camsim's CPU load. More... | |
DllExport int32_t | ExecuteSignalChangeCansim (CansimHandler Handle, const bool response) |
Execute signals change triggered on this event. It may be single signal groups or single signal which were not changed asynchronously. Signal group has to be >= 30! More... | |
DllExport int32_t | SetSignalControlCansim (CansimHandler Handle, const uint16_t SigHandler, const uint8_t ControlNumber, const uint32_t MinValue, const uint32_t MidValue, const uint32_t MaxValue) |
Set the Signal Control object TODO! More... | |
DllExport int32_t | ChangeSignalSgroupCansim (CansimHandler Handle, const uint8_t Sgroup, const uint16_t Value) |
Change signals values in whole group. Signal group has to be < 30! More... | |
DllExport int32_t | AddCrcCansim (CansimHandler Handle, const uint8_t *S_PDU_Kennungsfolge) |
DllExport int32_t | ChangeCrcCansim (CansimHandler Handle, const uint16_t MsgHandler, uint8_t *S_PDU_Kennungsfolge) |
DllExport int32_t | DisableCrcCansim (CansimHandler Handle, const uint16_t MsgHandler) |
DllExport int32_t | GetInternalThreadStatus (CansimHandler Handle) |
DllExport int32_t | ReadAsyncMsgCansim (CansimHandler Handle, const int32_t MsgHandler, PtrRecvMsgCansim DataStruct, uint8_t *Data, const uint8_t Length) |
Read buffered asynchronous message - nonblocking. More... | |
DllExport int32_t | ReadEepromCansim (CansimHandler Handle, const uint16_t address, const uint8_t length, uint8_t *data) |
Read Cansim internal EEPROM memory. More... | |
DllExport int32_t | WriteEepromCansim (CansimHandler Handle, const uint16_t address, const uint8_t length, const uint8_t *data) |
Write to internal EEPROM memory. More... | |
DllExport int32_t | GetTimeCansim (CansimHandler Handle, time_t *time) |
Get the Cansim unix time. More... | |
DllExport int32_t | SetTimeCansim (CansimHandler Handle, time_t time) |
Set the Cansim unix time. More... | |
DllExport int32_t | SetPrintFileCansim (CansimHandler Handle, FILE *PrintStream, LOG_LEVELS_CANSIM Level) |
DllExport int32_t | ClearPrintFileCansim (CansimHandler Handle, FILE *PrintStream, LOG_LEVELS_CANSIM Level) |
DllExport int32_t | SetPrintFunctionCansim (CansimHandler Handle, PrintFunc, LOG_LEVELS_CANSIM Level) |
DllExport int32_t | ClearPrintFunctionCansim (CansimHandler Handle, PrintFunc, LOG_LEVELS_CANSIM Level) |
DllExport void | PrintfErrCansim (CansimHandler Handle, const char *Text,...) |
DllExport void | PrintfInfCansim (CansimHandler Handle, const char *Text,...) |
#define DllExport __attribute__ ((visibility("default"))) |
CAN Sim DLL API (c)2019-2020 Digiteq automotive
typedef struct tagCanMessage CanMessage |
typedef void* CansimHandler |
typedef enum LOG_LEVELS_CANSIM LOG_LEVELS_CANSIM |
typedef void(* PrintFunc) (const char *) |
typedef struct tagCanMessage * PtrCanMessage |
typedef struct tagRecvMsgCansim * PtrRecvMsgCansim |
typedef struct tagRecvMsgCansim RecvMsgCansim |
enum LOG_LEVELS_CANSIM |
DllExport int32_t AddCrcCansim | ( | CansimHandler | Handle, |
const uint8_t * | S_PDU_Kennungsfolge | ||
) |
DllExport int32_t AddMessageCansim | ( | CansimHandler | Handle, |
const PtrCanMessage | Msg, | ||
const uint8_t * | Data | ||
) |
Msg | - Check tagCanMessage. Can be destroyed after executing this command. |
Data |
DllExport int32_t AddSignalCansim | ( | CansimHandler | Handle, |
const uint16_t | MsgHandler, | ||
const uint8_t | Group, | ||
const uint16_t | StartSymbol, | ||
const uint16_t | StopSymbol, | ||
const uint8_t | MuxInfo | ||
) |
MsgHandler | Handler of an existing CAN bus message provided by the Cansim. |
Group | - User defined group or direct group of signals (for group control): **Notes for current Cansim's firmware version 1.00: **User defined signals:
|
StartSymbol | - Position of first bit of signal in the message's data. (From 0) |
StopSymbol | - Position of last bit of signal in the message's data. (From 0) |
MuxInfo | - Can set counter signal (cumulating values) |
DllExport int32_t BlobRemoveCansim | ( | CansimHandler | Handle | ) |
DllExport int32_t BootloaderCansim | ( | CansimHandler | Handle | ) |
DllExport int32_t ChangeCrcCansim | ( | CansimHandler | Handle, |
const uint16_t | MsgHandler, | ||
uint8_t * | S_PDU_Kennungsfolge | ||
) |
DllExport int32_t ChangeSignalSgroupCansim | ( | CansimHandler | Handle, |
const uint8_t | Sgroup, | ||
const uint16_t | Value | ||
) |
Sgroup | - Signal group number. |
Value | - New value of the signal. |
DllExport int32_t ClearPrintFileCansim | ( | CansimHandler | Handle, |
FILE * | PrintStream, | ||
LOG_LEVELS_CANSIM | Level | ||
) |
DllExport int32_t ClearPrintFunctionCansim | ( | CansimHandler | Handle, |
PrintFunc | , | ||
LOG_LEVELS_CANSIM | Level | ||
) |
DllExport int32_t ConnectCansim | ( | CansimHandler | Handle, |
const char * | COMPort, | ||
const uint32_t | ReadTimeout, | ||
const uint32_t | WriteTimeout | ||
) |
COMPort | - Name or path to serial port. (e.g. COM3 - windows, /dev/ttyS1 - unix based systems) |
ReadTimeout | - Read timeout in millisecond. |
WriteTimeout | - Write timeout in millisecond. |
DllExport void DebugCommCansim | ( | CansimHandler | Handle, |
const char * | FileName | ||
) |
Open debugging file with all messages.
[in] | FileName | if NULL close file, if !=NULL open a file specified. |
DllExport void DeleteCansim | ( | CansimHandler | Handle | ) |
Handle |
DllExport int32_t DisableCrcCansim | ( | CansimHandler | Handle, |
const uint16_t | MsgHandler | ||
) |
DllExport int32_t DisableMessageCansim | ( | CansimHandler | Handle, |
const uint16_t | MsgHandler | ||
) |
MsgHandler | Message handler provided by Cansim |
DllExport int32_t DisableRequestCansim | ( | CansimHandler | Handle, |
const uint16_t | ReqHandler | ||
) |
ReqHandler | - Handler to the requested message. |
DllExport void DisconnectCansim | ( | CansimHandler | Handle | ) |
DllExport uint8_t DLC2length | ( | uint8_t * | DLC | ) |
DLC | - Data Length Code. If the value exceed 0x0f than is trimmed by 0x0f mask. |
DllExport int32_t EnableMessageCansim | ( | CansimHandler | Handle, |
const uint16_t | MsgHandler | ||
) |
MsgHandler | Message handler provided by Cansim |
DllExport int32_t EnableRequestCansim | ( | CansimHandler | Handle, |
const uint16_t | ReqHandler | ||
) |
ReqHandler | - Handler to the requested message. |
DllExport int32_t ExecuteSignalChangeCansim | ( | CansimHandler | Handle, |
const bool | response | ||
) |
DllExport int32_t GetHandlerCansim | ( | CansimHandler | Handle, |
const uint8_t | CanMap, | ||
const uint8_t | CanGatewayNumber, | ||
const uint32_t | CanID, | ||
const bool | ExtendedCanID, | ||
const bool | FastSlowSend, | ||
const bool | FD | ||
) |
CanMap | Mask of Cansim's CAN bus ports |
CanGatewayNumber | Number of Default CAN with gateway |
CanID | Can ID |
ExtendedCanID | Enables Extended CAN ID. |
FastSlowSend | Enables Fast Slow Send |
FD | Enables CAN FD |
DllExport int32_t GetInternalThreadStatus | ( | CansimHandler | Handle | ) |
DllExport int32_t GetTimeCansim | ( | CansimHandler | Handle, |
time_t * | time | ||
) |
Handle | - Cansim handler |
time | - time from cansim - internally max size 32bit. |
DllExport int32_t GetVersionCansim | ( | CansimHandler | Handle | ) |
DllExport CansimHandler NewCansim | ( | void | ) |
DllExport void PrintfErrCansim | ( | CansimHandler | Handle, |
const char * | Text, | ||
... | |||
) |
DllExport void PrintfInfCansim | ( | CansimHandler | Handle, |
const char * | Text, | ||
... | |||
) |
DllExport int32_t ReadAsyncMsgCansim | ( | CansimHandler | Handle, |
const int32_t | MsgHandler, | ||
PtrRecvMsgCansim | DataStruct, | ||
uint8_t * | Data, | ||
const uint8_t | Length | ||
) |
Handle | - handler to the Cansim. |
MsgHandler | - Handler of message registered by Cansim::RequestMessage |
DataStruct | - Structure for asynchronous messages. |
Data | - Pointer to allocated space for CAN messages data. NOTE: If is member Data = NULL, than data are not copied (could save some time). |
Length | - Length of the allocated buffer. If is smaller than CAN message payload length, than are copied only lower bytes |
DllExport int32_t ReadEepromCansim | ( | CansimHandler | Handle, |
const uint16_t | address, | ||
const uint8_t | length, | ||
uint8_t * | data | ||
) |
Handle | - Cansim handler |
address | - Start address to read |
length | - Data length in bytes |
data | - Output data buffer, must be >= length |
DllExport int32_t RebootCansim | ( | CansimHandler | Handle, |
const bool | Jump | ||
) |
Jump | if true reboot is realized by jump, else by watchdog |
timeout | - maximal timeout for the operation in ms |
DllExport int32_t RemoveMessageCansim | ( | CansimHandler | Handle, |
const uint16_t | MsgHandler | ||
) |
MsgHandler | Message handler provided by Cansim |
DllExport int32_t RemoveRequestCansim | ( | CansimHandler | Handle, |
const uint16_t | ReqHandler | ||
) |
ReqHandler | - Handler to the requested message. |
DllExport int32_t RemoveSignalCansim | ( | CansimHandler | Handle, |
const uint16_t | SigHandler | ||
) |
SigHandler | - handler of the signal |
DllExport int32_t RequestMessageCansim | ( | CansimHandler | Handle, |
const uint8_t | CanMap, | ||
const uint32_t | CanID, | ||
const bool | Enabled, | ||
const bool | ExtendedCanID, | ||
const uint8_t | DLC, | ||
const bool | CheckDLC, | ||
const bool | ReturnID, | ||
const uint8_t * | Mask | ||
) |
CanMap | - Map of cansim CAN bus ports where message will be received. |
CanID | - ID of received message. |
Enabled | - Enable request. |
ExtendedCanID | - Enable extended CAN ID |
DLC | - Data Length Code of the message |
CheckDLC | - Enable DLC check |
ReturnID | - Received message (from the cansim not CAN bus), will be identified by lower 16 bits of CAN ID, if false than by cansim's handler |
Mask | - Mask of tracking bits (message will be send only if bits matching mask are different), if is not specified than is substituted mask according to DLC |
DllExport int32_t RequestSignalCansim | ( | CansimHandler | Handle, |
const int32_t | MsgHandler, | ||
const uint16_t | StartSymbol, | ||
const uint16_t | StopSymbol | ||
) |
MsgHandler | - Handler of an existing request CAN bus message provided by the Cansim. |
StartSymbol | - Position of first bit of signal in the message's data. (From 0) |
StopSymbol | - Position of last bit of signal in the message's data. (From 0) |
DllExport int32_t ResetCansim | ( | CansimHandler | Handle | ) |
DllExport int32_t SetMessageDataCansim | ( | CansimHandler | Handle, |
const uint16_t | MsgHandler, | ||
const uint8_t * | Data, | ||
const uint8_t * | DataMask, | ||
const bool | Async, | ||
const bool | response | ||
) |
MsgHandler | Message handler provided by Cansim |
Data | New data buffer |
DataMask | Data buffer mask (mask bit which will be changed) |
async | Send message asynchronous (as soon as possible) |
response | bool true if you are interested in the cansim's answer |
DllExport int32_t SetPrintFileCansim | ( | CansimHandler | Handle, |
FILE * | PrintStream, | ||
LOG_LEVELS_CANSIM | Level | ||
) |
DllExport int32_t SetPrintFunctionCansim | ( | CansimHandler | Handle, |
PrintFunc | , | ||
LOG_LEVELS_CANSIM | Level | ||
) |
DllExport int32_t SetSignalControlCansim | ( | CansimHandler | Handle, |
const uint16_t | SigHandler, | ||
const uint8_t | ControlNumber, | ||
const uint32_t | MinValue, | ||
const uint32_t | MidValue, | ||
const uint32_t | MaxValue | ||
) |
SigHandler | |
ControlNumber | |
MinValue | |
MidValue | |
MaxValue |
DllExport int32_t SetTimeCansim | ( | CansimHandler | Handle, |
time_t | time | ||
) |
Handle | - Cansim handler |
time | - UNIX time to write - internally max size 32bit. |
DllExport int32_t SignalChangeValueCansim | ( | CansimHandler | Handle, |
const uint16_t | SigHandler, | ||
const uint16_t | Value, | ||
const bool | async, | ||
const bool | response | ||
) |
SigHandler | Handler of signal |
Value | New value of signal |
async | if true signal is change as soon as possible, else after SignalChangeExecute |
DllExport int32_t SignalReadValue32Cansim | ( | CansimHandler | Handle, |
const uint16_t | SigHandler, | ||
uint32_t * | Value, | ||
uint32_t * | TimeFromReceive, | ||
bool | GetLatest | ||
) |
SigHandler | - Handler of the requested message. |
Value | - Pointer to allocated space for return value. If is nullptr, than command is nonsense. |
TimeFromReceive | - Get time since message has been read from serial. Milliseconds. If is nullptr, than it save some time. |
GetLatest | - NOT IMPLEMENTED. In future: If true than is returned last received signal else next message in buffer (queue). |
DllExport int32_t SignalReadValue64Cansim | ( | CansimHandler | Handle, |
const uint16_t | SigHandler, | ||
uint64_t * | Value, | ||
uint32_t * | TimeFromReceive, | ||
bool | GetLatest | ||
) |
SigHandler | - Handler of the requested message. |
Value | - Pointer to allocated space for return value. If is nullptr, than command is nonsense. |
TimeFromReceive | - Get time since message has been read from serial. Milliseconds. If is nullptr, than it save some time. |
GetLatest | - NOT IMPLEMENTED. In future: If true than is returned last received signal else next message in buffer (queue). |
DllExport int32_t StartReceiverCansim | ( | CansimHandler | Handle | ) |
DllExport void StopReceiverCansim | ( | CansimHandler | Handle | ) |
DllExport int32_t WriteEepromCansim | ( | CansimHandler | Handle, |
const uint16_t | address, | ||
const uint8_t | length, | ||
const uint8_t * | data | ||
) |
Handle | - Cansim handler |
address | - Start address to write |
data | - Data to write |
length | - Data length |