CT2K NMEA2000 and J1939 Library. More...
#include <stdint.h>#include <stddef.h>#include <stdarg.h>#include <stdbool.h>Go to the source code of this file.
Data Structures | |
| struct | CONFIGURATION_INFORMATION_STRING_T |
| Defines the structure of strings used for transmitting and receiving PGN 1F016. More... | |
| struct | CAN_FRAME_T |
| CAN message structure. More... | |
| struct | CAN_DRIVER_FUNCTIONS_T |
| Structure used for the CAN Driver. More... | |
| struct | PGNDesc |
| PGN Description structure. More... | |
| struct | PGNDOB |
| Data object that contains information about a transmitted or received message. More... | |
| struct | DEVICE_NAME_FIELDS |
| Structure used for setting the Device Name. More... | |
| struct | DEVNAME |
| struct | NETDEVICE |
| Device information. More... | |
| struct | CTLIB_PROD_INFO |
| Product Information Structure. More... | |
| struct | NMEA2000SpecVersion |
| NMEA library version structure. More... | |
| struct | INPUT_PARAMS_T |
| Structure of Input Parameters. More... | |
| struct | PORTS_CONFIG_T |
| Structure Containing the Port Configuration the Library will use. More... | |
| struct | NMEA_REQUEST_FAILED_FIELDS_T |
| struct | NAME_CHANGE_COMMAND_RESPONSE_T |
Macros | |
| #define | PGN int32_t |
| Definitions of other types. | |
| #define | PGNGRPFUNC uint8_t |
| #define | INSTANCE int8_t |
| #define | PARAMETER int16_t |
| #define | CANBUF int8_t |
| #define | NETADDR uint8_t |
| #define | PGN_AddressClaim 60928 |
| NMEA2000 & J1939 PGN Required and used. | |
| #define | PGN_CommandedAddress 65240 |
| #define | PGN_Request 59904 |
| #define | PGN_Acknowledge 59392 |
| #define | PGN_NMEARequest 126208 |
| #define | PGN_Heartbeat 126993 |
| #define | PGN_ProductInformation 126996 |
| #define | PGN_ConfigurationInformation 126998 |
| #define | PGN_NMEAPGNList 126464 |
| #define | PGN_ISOConnectMgmt 60416 |
| Multi-Packet Specific PGNS. | |
| #define | PGN_ISODataTransport 60160 |
| #define | SINGLE_PKT_SIZE 8 |
| Packet Sizes. | |
| #define | FAST_PKT_SIZE 223 |
| #define | MULTI_PKT_SIZE 1785 |
| #define | PGN_CONFIGURATIONINFORMATION_SIZE 70 |
| PGN 1F016. | |
| #define | BYTES_IN_RAW_FRAME 8 |
| This is the max number of Bytes in a Raw CAN Frame. | |
Typedefs | |
| typedef uint32_t | __BIT |
| Type definitions. | |
| typedef uint32_t | CAN_PORT_T |
| typedef void(* | CT2KLibDiagnosticPrint_T) (const char *pFormatStr, va_list args, void *userData) |
| Type define for CTKLib's driver level print to console function. | |
| typedef int32_t(* | CT2KLibCanOpen_T) (CAN_PORT_T canPort, void *userData) |
| Type define for CT2KLib to Open the CAN Port. | |
| typedef int32_t(* | CT2KLibCanClose_T) (CAN_PORT_T canPort, void *userData) |
| Type define for CT2KLib to Close the CAN Port. | |
| typedef BUS_STATE_T(* | CT2KLibGetBusState_T) (CAN_PORT_T canPort, void *userData) |
| Type define for CT2KLib to get the current Bus State. | |
| typedef int32_t(* | CT2KLibTransmitFrame_T) (CAN_PORT_T canPort, CAN_FRAME_T *pFrame, void *userData) |
| Type define for CT2KLib to transmit a frame. | |
| typedef int32_t(* | CT2KLibReceiveFrameWait_T) (CAN_PORT_T *pCanPorts, uint32_t LengthOf_pCanPorts, CAN_FRAME_T *pFrame, CAN_PORT_T *pFromPort, uint32_t timeoutMs, void *userData) |
| Type define for CT2KLib to call to receive a Frame. | |
| typedef int32_t(* | CT2KLibBitRateSet_T) (CAN_PORT_T canPort, uint32_t bitRate, void *userData) |
| Type define for CT2KLib to call to set the Bit Rate of the Bus. | |
| typedef int(* | RCVRCB) (PGNDOB *pDOB, uintptr_t userData) |
| Type Definition for Received PGNs Callbacks. | |
| typedef int(* | ISOCallback_EA00) (PGNDOB *pDOB, uintptr_t userData) |
| Type Definition for PGN Request Callbacks. | |
| typedef int(* | CTLIB_ADDRCLAIM_CB) (CAN_PORT_T i8Port, NETDEVICE *pNetDevice, uintptr_t userData) |
| Type Definition for Address Claim Callback. | |
| typedef void(* | MLTIPCKTSENDCALLBACK) (uintptr_t userData) |
| Type Definition for Multi-Packet Send Callback. Is executed after a Multi-Packet has been sent. | |
| typedef bool(* | COMMANDEDADDRESSCALLBACK) (DEVNAME *devName, NETADDR commandedAddress, uintptr_t userData) |
| Type definition for Commanded address callback. Is executed after a commanded address message has been received (PGN 65240). | |
| typedef void(* | COMMANDCONFIGURATIONINFORMATIONCALLBACK) (const CAN_PORT_T i8Port, const CONFIGURATION_INFORMATION_STRING_T *pString1, GROUP_FUNCTION_PARAMETER_ERROR_CODE_T *pString1ErrCode, const CONFIGURATION_INFORMATION_STRING_T *pString2, GROUP_FUNCTION_PARAMETER_ERROR_CODE_T *pString2ErrCode, uintptr_t userData) |
| Type definition for group function command (PGN 1ED00) Configuration information(PGN 1F016) . | |
| typedef int(* | NMEA2K_RQ_CMD) (PGNDOB *pDOB, uintptr_t userData) |
| NMEA2000 Level A Request/Command/Acknowledge PGN Callbacks. | |
| typedef NAME_CHANGE_COMMAND_RESPONSE_T(* | CommandedNameChangeNotification) (CAN_PORT_T i8Port, DEVNAME commandedNameInformation, uintptr_t userData) |
| Type Definition for Name Change Command Notification. | |
| typedef GROUP_FUNCTION_TRANSMIT_INTERVAL_ERROR_CODE_T(* | RequestedHeartbeatUpdateRateChangeNotification) (CAN_PORT_T i8Port, uint32_t requestedUpdateRate_ms, NETADDR sourceDevice, uintptr_t userData) |
| Type definition for Heartbeat update rate notification. | |
Functions | |
| INPUT_PARAMS_T | CT2KLibGetPGNTableRequiredMemorySize (const PGNDesc *pDesc, uint32_t tableSize, uint16_t numberOfPorts) |
| Calculate the required size based on the provided PGNDesc Table. | |
| void | CT2KLibInitEx (INPUT_PARAMS_T *inputParams, PORTS_CONFIG_T *ports, uint32_t numberOfPorts, CAN_DRIVER_FUNCTIONS_T canDriverFunctions) |
| Initialises the CT2K Library. | |
| void | CT2KLibDeinit (void) |
| De-initialises the CT2K Library. | |
| CTCAN_STATUS | CT2KLibStart (void) |
| Open the CAN Port and start the Library. | |
| bool | CT2KLibIsRunning (void) |
| Query the State of the Library. | |
| void | CT2KLibStop (void) |
| Stop the Library. | |
| CTCAN_STATUS | CT2KLibRestartCANPorts (PORTS_CONFIG_T *ports, uint32_t numberOfPorts) |
| Restart the CAN Ports with a different configuration. | |
| CTCAN_STATUS | CT2KLibEnableDebug (uint32_t loggedMessagesBitmask, CT2KLibDiagnosticPrint_T printFunction, void *userData) |
| Enable Debug Prints. | |
| CTCAN_STATUS | CT2KLibInstallPGNTable (CAN_PORT_T portNumber, const PGNDesc *pDesc, uint16_t tableSize) |
| Install the PGN Table in the Library Duplicates are not allowed and will trigger an assert and a fail. | |
| CTCAN_STATUS | CT2KLibUninstallPGNTable (CAN_PORT_T portNumber, const PGNDesc *pDesc) |
| Uninstall a PGN Table Installed using CT2KLibInstallPGNTable() | |
| CTSTATE | CT2KLibGetState (CAN_PORT_T i8Port) |
| Get the Library status on the specified Port. | |
| CTCAN_STATUS | CT2KLibSetAppProductInfo (CAN_PORT_T i8Port, CTLIB_PROD_INFO *pProdInfo) |
| Set and the Product Information via the NMEA2000 PGN. | |
| CTCAN_STATUS | CT2KLibSetConfigurationInformation_1F016 (CAN_PORT_T i8Port, const char *field1, size_t field1_Length, const char *field2, size_t field2_Length, const char *field3, size_t field3_Length) |
| Set the information shared with other devices via the Configuration Information PGN (1F016). | |
| CTCAN_STATUS | CT2KLibSetConfigurationInformation_1F016_EX (CAN_PORT_T i8Port, const CONFIGURATION_INFORMATION_STRING_T *field1, const CONFIGURATION_INFORMATION_STRING_T *field2, const CONFIGURATION_INFORMATION_STRING_T *field3) |
| Set the information shared with other devices via the Configuration Information PGN (1F016). | |
| CTCAN_STATUS | CT2KLibSetAddress (CAN_PORT_T i8Port, DEVNAME *pName, NETADDR u8SeedAddress) |
| Assigns the name and address to the device. | |
| CTCAN_STATUS | CT2KLibAddValidAddressRange (CAN_PORT_T i8Port, uint8_t startAddress, uint8_t endAddress) |
| Restricts the addressses that can be assigned to the device. | |
| CTCAN_STATUS | CT2KLibResetValidAddressRange (CAN_PORT_T i8Port) |
| Resets the valid address range, cancelling the effect of any previous calls to CT2KLibAddValidAddressRange. | |
| NETADDR | CT2KLibGetMyAddress (CAN_PORT_T i8Port) |
| Returns the devices CAN Address for the specified port. | |
| void | CT2KLibPackDeviceNameFields (const DEVICE_NAME_FIELDS *pFields, uint8_t *pPackedFields) |
| Pack DEVICE_NAME_FIELDS struct into an 8 byte array. | |
| void | CT2KLibUnpackDeviceNameFields (const uint8_t *pPackedFields, DEVICE_NAME_FIELDS *pFields) |
| Unpack 8 byte array into DEVICE_NAME_FIELDS struct. | |
| const NMEA2000SpecVersion * | CTLIBGetNMEA2KLibVersion (void) |
| Get the NMEA2000 Database Version the library uses. | |
| const char * | CT2KGetLibVersion (void) |
| Get the version number of CT2KLib. | |
| CTCAN_STATUS | CT2KLibSnoopNetwork (CAN_PORT_T i8Port) |
| Sends Global Address Claim request using the Request PGN on the specified port. | |
| CTCAN_STATUS | CT2KSetPGNReceiveCallback (CAN_PORT_T i8Port, PGN i32PGN, RCVRCB rCB, uintptr_t userdata) |
| Register a Callback function when a Message associated with the Specified PGN is received. | |
| CTCAN_STATUS | CT2KClearPGNReceiveCallback (CAN_PORT_T i8Port, PGN i32PGN) |
| Deregister the Callback function that was registered with CT2KSetPGNReceiveCallback() | |
| CTCAN_STATUS | CT2KSetPGNISORequestReceivedCallback (CAN_PORT_T i8Port, PGN i32PGN, ISOCallback_EA00 regCB, uintptr_t userData) |
| Register a Callback function when a Message associated with the Specified PGN is received. | |
| CTCAN_STATUS | CT2KLibAddrClaimReceiveCallback (CTLIB_ADDRCLAIM_CB AddrClaimCB, uintptr_t userData) |
| Register a callback function that will be triggered when an address claim occurs. | |
| CTCAN_STATUS | CT2KLibSendPGN (CAN_PORT_T i8Port, NETADDR u8DestAddr, PGN i32PGN, void *pData, uint16_t u16DataLen) |
| Send a Message using the specified PGN. Valid only for Single and Fast Packets. | |
| CTCAN_STATUS | CT2KLibSendPGNNow (CAN_PORT_T i8Port, NETADDR u8DestAddr, PGN i32PGN, void *pData, uint16_t u16DataLen) |
| Functions the same as CT2KLibSendPGN Except allows you to mark a frame as to be sent immediately. | |
| CTCAN_STATUS | CT2KLibSendPGNMultiPkt (CAN_PORT_T i8Port, NETADDR u8DestAddr, PGN i32PGN, void *pData, uint16_t u16DataLen, MLTIPCKTSENDCALLBACK multiPktClbk, uintptr_t userdata, bool isBAM) |
| Send a Message using the specified PGN. | |
| CTCAN_STATUS | CT2KSetGroupFunctionCallback (CAN_PORT_T i8Port, PGN i32PGN, NMEA2K_RQ_CMD regCB, uintptr_t userData) |
| NMEA 2000 Level A - Request, Command, Acknowledge PGN Functions. | |
| CTCAN_STATUS | CT2KNMEA2KSendAcknowledge (CAN_PORT_T i8Port, PGN i32PGN, NETADDR u8DestAddr, MULTIPKT_TYPE_T transmitMethod, GROUP_FUNCTION_PGN_ERROR_CODE_T pgnErrorCode, GROUP_FUNCTION_TRANSMIT_INTERVAL_ERROR_CODE_T transmissionErrorCode, uint8_t numberOfRequestedParams, NMEA_REQUEST_FAILED_FIELDS_T *failedFields, uint8_t length) |
| Send a NMEA2K Acknowledge Message (PGN 126208) | |
| CTCAN_STATUS | CT2KRegisterCallbackOnCommandedNameChange (CAN_PORT_T i8Port, CommandedNameChangeNotification callBack, uintptr_t userData) |
| NMEA 2000 Level A - Commanded Name (0xEE00) Functionality. | |
| CTCAN_STATUS | CT2KRegisterCallbackOnRequestedHeartbeatRateChange (CAN_PORT_T i8Port, RequestedHeartbeatUpdateRateChangeNotification callback, uintptr_t userData) |
| This allows you to register for a callback from the library if we receive a request to change the update rate of the heartbeat message. | |
| CTCAN_STATUS | CT2KSetHeartbeatUpdateRate (CAN_PORT_T i8Port, uint32_t updateRate_ms) |
| This allows you to set the update rate of the NMEA2000 heartbeat message. | |
| CTCAN_STATUS | CT2KLibRegisterCommandedAddressCallback (CAN_PORT_T i8Port, COMMANDEDADDRESSCALLBACK callback, uintptr_t userData) |
| This allows registration of a callback to check whether or not the device should change to the specified address on receipt of the CommandedAddress PGN. | |
| CTCAN_STATUS | CT2KLibRegisterCommandedConfigurationInformationCallback (COMMANDCONFIGURATIONINFORMATIONCALLBACK callback, uintptr_t userData) |
| This allows registration of a callback to check whether or not the device should change it's configuration information to the specified strings on receipt of the Configuration Information PGN change command. | |
CT2K NMEA2000 and J1939 Library.
Definition in file CT2KLib.h.