-
-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Work on Devices.Spi #428
Work on Devices.Spi #428
Conversation
- update code to latest version of the managed class library - move gpioPort[] to targetPAL to allow reuse - work on NativeTransfer for byte[] transfers (code improvement, add comments) Signed-off-by: José Simões <jose.simoes@eclo.solutions>
Hi @josesimoes, I'm nanoFramework bot. A human will be reviewing it shortly. 😉 |
@@ -273,22 +265,22 @@ HRESULT Library_win_dev_spi_native_Windows_Devices_Spi_SpiDevice::GetDeviceSelec | |||
|
|||
char* retVal = ""; | |||
#if STM32_SPI_USE_SPI1 | |||
strcat(retVal,"SPI1"); | |||
strcat(retVal,"SPI1,"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not agree with this change.
What if the config is only using SPI1 ? You will end up with "SPI1," as a result string, not "SPI1".
Same for the following changes on other SPIx, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you are splitting this string in managed code it will work OK.
Consider that you have SPI2 and SPI5 enable for example.
With the previous approach it would end up on ",SPI2,SPI5" now it's "SPI2,SPI5,"
Ideally we would add the "," only as required but that would mean adding a lot of code to handle just this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand.
A quick and dirty fix, for both versions of code, could then be to remove the first/last char of the resulting string if it is a "," ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would work! And it just requires a couple of lines. 👍
Care to add that to your incoming PR? 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I will do that. Which version shall I use ? I would not like to remove the wrong char :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to choose the one that works best for you.
In the end it will end up on a nice and properly formatted string. 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will take yours, because the last char of the resulting string will always be a comma ;) No need to think more than "remove the last char of that string" ;)
I will only add that comma on the "SPI6" string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strcat(retval, retval = "" ? "SPI1" : ", SPI1") does this compute ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does, but... Won't that require an extra IF clause on each string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@piwi1263 : Systematically removing the last char will be faster and shorter, I think ;) No need to think : remove !
Signed-off-by: José Simões jose.simoes@eclo.solutions