Legacy: Formatting

v0.3.0-dev
Paul Hollinsky 2022-02-21 20:56:49 -05:00
parent dfd8768bbf
commit 0f9bf83c89
1 changed files with 155 additions and 145 deletions

View File

@ -58,7 +58,8 @@ static NeoDevice OldNeoDeviceFromNew(const neodevice_t *newnd)
oldnd.SerialNumber = icsneo_serialStringToNum(newnd->serial);
oldnd.NumberOfClients = 0;
oldnd.MaxAllowedClients = 1;
static_assert(sizeof(neodevice_handle_t) == sizeof(oldnd.Handle), "neodevice_handle_t size must be sizeof(int) for compatibility reasons");
static_assert(sizeof(neodevice_handle_t) == sizeof(oldnd.Handle),
"neodevice_handle_t size must be sizeof(int) for compatibility reasons");
oldnd.Handle = newnd->handle;
return oldnd;
}
@ -197,7 +198,8 @@ static inline unsigned int GetVnetAgnosticNetid(size_t fullNetid)
}
//Basic Functions
int LegacyDLLExport icsneoFindDevices(NeoDeviceEx *devs, int *devCount, unsigned int *devTypes, unsigned int devTypeCount, POptionsFindNeoEx *POptionsFindNeoEx, unsigned int *zero)
int LegacyDLLExport icsneoFindDevices(NeoDeviceEx* devs, int* devCount, unsigned int* devTypes, unsigned int devTypeCount,
POptionsFindNeoEx* POptionsFindNeoEx, unsigned int* zero)
{
if (!devs || !devCount)
return 0;
@ -335,7 +337,7 @@ int LegacyDLLExport icsneoClosePort(void *hObject, int *pNumberOfErrors)
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return icsneo_closeDevice(device);
}
@ -359,7 +361,7 @@ int LegacyDLLExport icsneoGetMessages(void *hObject, icsSpyMessage *pMsg, int *p
static neomessage_t messages[20000];
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
size_t messageCount = 20000;
if (!icsneo_getMessages(device, messages, &messageCount, 0))
@ -382,11 +384,12 @@ int LegacyDLLExport icsneoTxMessages(void *hObject, icsSpyMessage *pMsg, int lNe
return icsneoTxMessagesEx(hObject, pMsg, lNetworkID, lNumMessages, nullptr, 0);
}
int LegacyDLLExport icsneoTxMessagesEx(void *hObject, icsSpyMessage *pMsg, unsigned int lNetworkID, unsigned int lNumMessages, unsigned int *NumTxed, unsigned int zero2)
int LegacyDLLExport icsneoTxMessagesEx(void* hObject, icsSpyMessage* pMsg, unsigned int lNetworkID, unsigned int lNumMessages,
unsigned int* NumTxed, unsigned int zero2)
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
neomessage_t newmsg;
unsigned int temp = 0;
if (NumTxed == nullptr)
@ -413,7 +416,7 @@ int LegacyDLLExport icsneoTxMessagesEx(void *hObject, icsSpyMessage *pMsg, unsig
newmsg.status.statusBitfield[3] = oldmsg.StatusBitField4;
if (oldmsg.Protocol == SPY_PROTOCOL_CANFD)
newmsg.status.canfdFDF = true;
if (icsneo_transmit(device, &newmsg))
if (icsneo_transmit(device, reinterpret_cast<neomessage_t*>(&newmsg)))
(*NumTxed)++;
}
return lNumMessages == *NumTxed;
@ -428,7 +431,7 @@ int LegacyDLLExport icsneoEnableNetworkRXQueue(void *hObject, int iEnable)
int LegacyDLLExport icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg, double* pTimeStamp) {
if(!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
uint16_t resolution = 0;
if (!icsneo_getTimestampResolution(device, &resolution))
@ -448,14 +451,15 @@ int LegacyDLLExport icsneoGetTimeStampForMsg(void* hObject, icsSpyMessage* pMsg,
return true;
}
void LegacyDLLExport icsneoGetISO15765Status(void *hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus, int *lTxStatus, int *lRxStatus)
void LegacyDLLExport icsneoGetISO15765Status(void* hObject, int lNetwork, int lClearTxStatus, int lClearRxStatus,
int* lTxStatus, int* lRxStatus)
{
// TODO Implement
return;
}
void LegacyDLLExport icsneoSetISO15765RxParameters(void *hObject, int lNetwork, int lEnable, spyFilterLong *pFF_CFMsgFilter, icsSpyMessage *pTxMsg,
int lCFTimeOutMs, int lFlowCBlockSize, int lUsesExtendedAddressing, int lUseHardwareIfPresent)
void LegacyDLLExport icsneoSetISO15765RxParameters(void* hObject, int lNetwork, int lEnable, spyFilterLong* pFF_CFMsgFilter,
icsSpyMessage* pTxMsg, int lCFTimeOutMs, int lFlowCBlockSize, int lUsesExtendedAddressing, int lUseHardwareIfPresent)
{
// TODO Implement
return;
@ -478,7 +482,7 @@ int LegacyDLLExport icsneoGetFireSettings(void *hObject, SFireSettings *pSetting
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1);
}
@ -486,7 +490,7 @@ int LegacyDLLExport icsneoSetFireSettings(void *hObject, SFireSettings *pSetting
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -496,7 +500,7 @@ int LegacyDLLExport icsneoGetVCAN3Settings(void *hObject, SVCAN3Settings *pSetti
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1);
}
@ -504,7 +508,7 @@ int LegacyDLLExport icsneoSetVCAN3Settings(void *hObject, SVCAN3Settings *pSetti
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -514,7 +518,7 @@ int LegacyDLLExport icsneoGetFire2Settings(void *hObject, SFire2Settings *pSetti
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1);
}
@ -522,7 +526,7 @@ int LegacyDLLExport icsneoSetFire2Settings(void *hObject, SFire2Settings *pSetti
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -532,7 +536,7 @@ int LegacyDLLExport icsneoGetVCANRFSettings(void *hObject, SVCANRFSettings *pSet
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1);
}
@ -540,7 +544,7 @@ int LegacyDLLExport icsneoSetVCANRFSettings(void *hObject, SVCANRFSettings *pSet
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -550,7 +554,7 @@ int LegacyDLLExport icsneoGetVCAN412Settings(void *hObject, SVCAN412Settings *pS
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1);
}
@ -558,7 +562,7 @@ int LegacyDLLExport icsneoSetVCAN412Settings(void *hObject, SVCAN412Settings *pS
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -568,7 +572,7 @@ int LegacyDLLExport icsneoGetRADGalaxySettings(void *hObject, SRADGalaxySettings
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1);
}
@ -576,7 +580,7 @@ int LegacyDLLExport icsneoSetRADGalaxySettings(void *hObject, SRADGalaxySettings
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -586,7 +590,7 @@ int LegacyDLLExport icsneoGetRADStar2Settings(void *hObject, SRADStar2Settings *
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!(icsneo_settingsReadStructure(device, pSettings, iNumBytes) + 1);
}
@ -594,7 +598,7 @@ int LegacyDLLExport icsneoSetRADStar2Settings(void *hObject, SRADStar2Settings *
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -604,22 +608,24 @@ int LegacyDLLExport icsneoSetBitRate(void *hObject, int BitRate, int NetworkID)
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (!icsneo_setBaudrate(device, (uint16_t)NetworkID, BitRate))
return false;
return icsneo_settingsApply(device);
}
int LegacyDLLExport icsneoSetFDBitRate(void* hObject, int BitRate, int NetworkID) {
int LegacyDLLExport icsneoSetFDBitRate(void* hObject, int BitRate, int NetworkID)
{
if(!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if(!icsneo_setFDBaudrate(device, (uint16_t)NetworkID, BitRate))
return false;
return icsneo_settingsApply(device);
}
int LegacyDLLExport icsneoGetDeviceParameters(void* hObject, char* pParameter, char* pValues, short ValuesLength) {
int LegacyDLLExport icsneoGetDeviceParameters(void* hObject, char* pParameter, char* pValues, short ValuesLength)
{
// TODO Implement
return false;
}
@ -643,7 +649,8 @@ int LegacyDLLExport icsneoGetErrorMessages(void *hObject, int *pErrorMsgs, int *
return false;
}
int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, TCHAR *szErrorDescriptionShort, TCHAR *szErrorDescriptionLong, int *lMaxLengthShort, int *lMaxLengthLong, int *lErrorSeverity, int *lRestartNeeded)
int LegacyDLLExport icsneoGetErrorInfo(int lErrorNumber, TCHAR* szErrorDescriptionShort, TCHAR* szErrorDescriptionLong,
int* lMaxLengthShort, int* lMaxLengthLong, int* lErrorSeverity, int* lRestartNeeded)
{
// TODO Implement
return false;
@ -662,7 +669,8 @@ int LegacyDLLExport icsneoISO15765_DisableNetworks(void *hObject)
return false;
}
int LegacyDLLExport icsneoISO15765_TransmitMessage(void *hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage *pMsg, unsigned long ulBlockingTimeout)
int LegacyDLLExport icsneoISO15765_TransmitMessage(void* hObject, unsigned long ulNetworkID, stCM_ISO157652_TxMessage* pMsg,
unsigned long ulBlockingTimeout)
{
// TODO Implement
return false;
@ -681,7 +689,7 @@ int LegacyDLLExport icsneoValidateHObject(void *hObject)
{
if (&it->second == hObject)
{
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (icsneo_isValidNeoDevice(device))
return true;
}
@ -699,7 +707,7 @@ int LegacyDLLExport icsneoGetSerialNumber(void *hObject, unsigned int *iSerialNu
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
*iSerialNumber = icsneo_serialStringToNum(device->serial);
return true;
}
@ -708,7 +716,7 @@ int LegacyDLLExport icsneoEnableDOIPLine(void* hObject, bool enable)
{
if(!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return icsneo_setDigitalIO(device, ICSNEO_IO_ETH_ACTIVATION, 1, enable);
}
@ -786,13 +794,15 @@ int LegacyDLLExport icsneoScriptWriteAppSignal(void *hObject, unsigned int iInde
}
//Deprecated (but still suppored in the DLL)
int LegacyDLLExport icsneoOpenPortEx(void *lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB, int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char *bNetworkID, int *hObject)
int LegacyDLLExport icsneoOpenPortEx(void* lPortNumber, int lPortType, int lDriverType, int lIPAddressMSB,
int lIPAddressLSBOrBaudRate, int bConfigRead, unsigned char* bNetworkID, int* hObject)
{
// TODO Implement
return false;
}
int LegacyDLLExport icsneoOpenPort(int lPortNumber, int lPortType, int lDriverType, unsigned char *bNetworkID, unsigned char *bSCPIDs, int *hObject)
int LegacyDLLExport icsneoOpenPort(int lPortNumber, int lPortType, int lDriverType, unsigned char *bNetworkID,
unsigned char* bSCPIDs, int* hObject)
{
// TODO Implement
return false;
@ -802,7 +812,7 @@ int LegacyDLLExport icsneoEnableNetworkCom(void *hObject, int Enable)
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (Enable)
return icsneo_goOnline(device);
@ -810,13 +820,15 @@ int LegacyDLLExport icsneoEnableNetworkCom(void *hObject, int Enable)
return icsneo_goOffline(device);
}
int LegacyDLLExport icsneoFindAllCOMDevices(int lDriverType, int lGetSerialNumbers, int lStopAtFirst, int lUSBCommOnly, int *p_lDeviceTypes, int *p_lComPorts, int *p_lSerialNumbers, int *lNumDevices)
int LegacyDLLExport icsneoFindAllCOMDevices(int lDriverType, int lGetSerialNumbers, int lStopAtFirst, int lUSBCommOnly,
int* p_lDeviceTypes, int* p_lComPorts, int* p_lSerialNumbers, int* lNumDevices)
{
// TODO Implement
return false;
}
int LegacyDLLExport icsneoOpenNeoDeviceByChannels(NeoDevice *pNeoDevice, void **hObject, unsigned char *uChannels, int iSize, int bConfigRead, int iOptions)
int LegacyDLLExport icsneoOpenNeoDeviceByChannels(NeoDevice* pNeoDevice, void** hObject, unsigned char* uChannels, int iSize,
int bConfigRead, int iOptions)
{
// TODO Implement
return false;
@ -826,7 +838,7 @@ int LegacyDLLExport icsneoGetVCAN4Settings(void *hObject, SVCAN4Settings *pSetti
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
return !!icsneo_settingsReadStructure(device, pSettings, iNumBytes);
}
@ -834,7 +846,7 @@ int LegacyDLLExport icsneoSetVCAN4Settings(void *hObject, SVCAN4Settings *pSetti
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (bSaveToEEPROM)
return icsneo_settingsApplyStructure(device, pSettings, iNumBytes);
return icsneo_settingsApplyStructureTemporary(device, pSettings, iNumBytes);
@ -845,7 +857,7 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void *hObject, EPlasmaIonVnetCha
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
unsigned long ulDeviceType = device->type;
@ -906,12 +918,13 @@ int LegacyDLLExport icsneoGetDeviceSettingsType(void *hObject, EPlasmaIonVnetCha
return 1;
}
int LegacyDLLExport icsneoSetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, int bSaveToEEPROM, EPlasmaIonVnetChannel_t vnetSlot)
int LegacyDLLExport icsneoSetDeviceSettings(void* hObject, SDeviceSettings* pSettings, int iNumBytes, int bSaveToEEPROM,
EPlasmaIonVnetChannel_t vnetSlot)
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
const size_t offset = size_t(&pSettings->Settings) - size_t(pSettings);
@ -926,7 +939,7 @@ int LegacyDLLExport icsneoGetDeviceSettings(void* hObject, SDeviceSettings* pSet
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t* device = (neodevice_t*)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (icsneoGetDeviceSettingsType(hObject, vnetSlot, &pSettings->DeviceSettingType) == 0)
return false;
@ -939,7 +952,7 @@ int LegacyDLLExport icsneoSetBitRateEx(void *hObject, unsigned long BitRate, int
{
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
if (!icsneo_setBaudrate(device, (uint16_t)NetworkID, BitRate))
return false;
@ -1082,7 +1095,7 @@ int LegacyDLLExport icsneoJ2534Cmd(void *hObject, unsigned char *CmdBuf, short L
if (!icsneoValidateHObject(hObject))
return false;
neodevice_t *device = (neodevice_t *)hObject;
neodevice_t* device = reinterpret_cast<neodevice_t*>(hObject);
switch (*CmdBuf)
{
@ -1233,11 +1246,8 @@ int LegacyDLLExport icsneoGetBusVoltage(void *hObject, unsigned long *pVBusVolta
return false;
}
int LegacyDLLExport icsneoOpenRemoteNeoDevice(const char *pIPAddress,
NeoDevice *pNeoDevice,
void **hObject,
unsigned char *bNetworkIDs,
int iOptions)
int LegacyDLLExport icsneoOpenRemoteNeoDevice(const char* pIPAddress, NeoDevice* pNeoDevice, void** hObject,
unsigned char* bNetworkIDs, int iOptions)
{
return false;
}