Macro analysis - help wanted
-
I am posting this here because I had no luck elsewhere. Since it is really NOT C/C++ question I like to provide details when somebody answers. I have high regards for this forum , but from experience elsewhere I hesitate to waste forum and mine time with details and then get no response. I hope it is understandable and nobody takes an offense. I like help with analysis of this call, starting with the "command" macro. I have basic understanding of ioctl and I am successfully implementing this call to send data. I am unable to receive data and like to go thru the command macro expansion to gain understanding how it supposedly works. Since the main macro expands to more macros and I get lost... Again - I'll provide details / links etc. to whomever responds. Cheers Vaclav
ret = ioctl(fd, SPI\_IOC\_MESSAGE(1), &tr);
-
I am posting this here because I had no luck elsewhere. Since it is really NOT C/C++ question I like to provide details when somebody answers. I have high regards for this forum , but from experience elsewhere I hesitate to waste forum and mine time with details and then get no response. I hope it is understandable and nobody takes an offense. I like help with analysis of this call, starting with the "command" macro. I have basic understanding of ioctl and I am successfully implementing this call to send data. I am unable to receive data and like to go thru the command macro expansion to gain understanding how it supposedly works. Since the main macro expands to more macros and I get lost... Again - I'll provide details / links etc. to whomever responds. Cheers Vaclav
ret = ioctl(fd, SPI\_IOC\_MESSAGE(1), &tr);
What is to know it is obvious what it is and does .. it writes an SPI block command field index 1 (rx_buf), to the SPI driver. I would also warn you that macro uses sizeof struct spi_ioc_transfer and it can not be used raw in a C++ program .. it will fail dramatically. This is mandatory if you wish to use that header in C++ as that is a linux C base file.
extern "C" {
#include }The alternative is to change the header file, you did this dance earlier. This is one of those things when you start mixing C++ and C, C is it's own language and is not 100% compatible with C++ which has gone it's own way with some syntax. They are getting less and less compatible and so the general recommendation is compile C files with a C compiler and bring them in at the link stage. Other than that take a lot of care with C header files.
In vino veritas
-
What is to know it is obvious what it is and does .. it writes an SPI block command field index 1 (rx_buf), to the SPI driver. I would also warn you that macro uses sizeof struct spi_ioc_transfer and it can not be used raw in a C++ program .. it will fail dramatically. This is mandatory if you wish to use that header in C++ as that is a linux C base file.
extern "C" {
#include }The alternative is to change the header file, you did this dance earlier. This is one of those things when you start mixing C++ and C, C is it's own language and is not 100% compatible with C++ which has gone it's own way with some syntax. They are getting less and less compatible and so the general recommendation is compile C files with a C compiler and bring them in at the link stage. Other than that take a lot of care with C header files.
In vino veritas
Thanks Leon, I have no issue writing the data. I just do not get how the initial command gets to read the data. However, I just discovered that I can use Eclipse to step thru the macro. But that is now immaterial since another "discovery" uncovered that I am coding for SPI and the hardware is set for 3 or 4 wire "serial communication" not even close to SPI. I think I'll shelve the local LCD/TFT and start coding for remote - bluetooth - keyboard and real monitor. Maybe some day I'll find small LCD/TFT with REAL SPI and not these "cellphones" surplus modules I have been fighting with. Subject temporary inactive. Have a great summer down under. We are freezing in Huston! Cheers Vaclav
-
Thanks Leon, I have no issue writing the data. I just do not get how the initial command gets to read the data. However, I just discovered that I can use Eclipse to step thru the macro. But that is now immaterial since another "discovery" uncovered that I am coding for SPI and the hardware is set for 3 or 4 wire "serial communication" not even close to SPI. I think I'll shelve the local LCD/TFT and start coding for remote - bluetooth - keyboard and real monitor. Maybe some day I'll find small LCD/TFT with REAL SPI and not these "cellphones" surplus modules I have been fighting with. Subject temporary inactive. Have a great summer down under. We are freezing in Huston! Cheers Vaclav
When you get back if it isn't SPI (which is both 3 and 4 wire BTW) it will be MIPI display interface. Drivers again in the linux driver Display Serial Interface - Wikipedia[^]
In vino veritas
-
I am posting this here because I had no luck elsewhere. Since it is really NOT C/C++ question I like to provide details when somebody answers. I have high regards for this forum , but from experience elsewhere I hesitate to waste forum and mine time with details and then get no response. I hope it is understandable and nobody takes an offense. I like help with analysis of this call, starting with the "command" macro. I have basic understanding of ioctl and I am successfully implementing this call to send data. I am unable to receive data and like to go thru the command macro expansion to gain understanding how it supposedly works. Since the main macro expands to more macros and I get lost... Again - I'll provide details / links etc. to whomever responds. Cheers Vaclav
ret = ioctl(fd, SPI\_IOC\_MESSAGE(1), &tr);
You did not mention what compiler you are using, but with VC++, there is the
/P
option that will expand all preprocessor directives into a separate.I
file that you can then look at. That would be the best way to see the final result of all the preprocessor "replacements.""One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
When you get back if it isn't SPI (which is both 3 and 4 wire BTW) it will be MIPI display interface. Drivers again in the linux driver Display Serial Interface - Wikipedia[^]
In vino veritas
-
You did not mention what compiler you are using, but with VC++, there is the
/P
option that will expand all preprocessor directives into a separate.I
file that you can then look at. That would be the best way to see the final result of all the preprocessor "replacements.""One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles