Hi,
I have a generic module to manage the ethernet.
This module should be used on project which running on MQX 4.1 and other on MQX 4.2.
But to close a socket, the way is different according MQX revision:
Shutdown for MQX 4.1
closesocket for MQX 4.2.
Then I like to do a macro to call one or other funtion according the MQX version.
I like this will automatic by reading the linked MQX version.
Unfortally, I only found a constant for the MQX version : _mqx_version_number
Are the the same but in macro? (i.e #define _MQX_VERSION_NUMBER 0x04020001)
this to have a faster code by resolve the problem in pre compile time.
Thank:smileyhappy:
Solved! Go to Solution.
Hello
I found the following define which correspond to my need:
MQX_VERSION
Defined in mqx.h
So I made the following implementation
#if (MQX_VERSION < 420) #define DV_Eth_iCloseSocket(socket) shutdown(socket, FLAG_CLOSE_TX) #else #define DV_Eth_iCloseSocket(socket) closesocket(socket) #endif
Hello Arnaud,
There is not a macro, however you can use the _mqx_version_number or the _mqx_version values.
In addition you can use the _mqx_version, this is a string that indicates the version of MQX RTOS.
I hope this helps.
Have a great day,
Sol
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Yes I seen that, but this is not macro,
I would like do following:
#if (_mqx_version = "4.2.0")
#define DV_Eth_iCloseSocket(socket) closesocket(socket)
#elif (_mqx_version = "4.1.0")
#define DV_Eth_iCloseSocket(socket) shutdown(socket, FLAG_CLOSE_TX)
#endif
But like "mqx_version" is a constant, it value cannot be used in pre compile time!:smileycry:
and then if in the .c code I do following:
if (_mqx_version = "4.2.0")
{
closesocket(socket);
}
else if (_mqx_version = "4.1.0")
{
shutdown(socket, FLAG_CLOSE_TX);
}
This not link because according used OS, closesocket or shutdown API is not existing..
Hello
I found the following define which correspond to my need:
MQX_VERSION
Defined in mqx.h
So I made the following implementation
#if (MQX_VERSION < 420) #define DV_Eth_iCloseSocket(socket) shutdown(socket, FLAG_CLOSE_TX) #else #define DV_Eth_iCloseSocket(socket) closesocket(socket) #endif