Skip to content
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

Merged
merged 1 commit into from
Aug 16, 2017
Merged

Work on Devices.Spi #428

merged 1 commit into from
Aug 16, 2017

Conversation

josesimoes
Copy link
Member

  • 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

- 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>
@josesimoes josesimoes added Series: STM32xx Everything related specifically with STM32 targets Type: enhancement labels Aug 16, 2017
@nfbot
Copy link
Member

nfbot commented Aug 16, 2017

Hi @josesimoes,

I'm nanoFramework bot.
Thank you for your contribution!

A human will be reviewing it shortly. 😉

@josesimoes josesimoes merged commit 43960e0 into nanoframework:master Aug 16, 2017
@josesimoes josesimoes deleted the work-on-spi branch August 16, 2017 18:26
@@ -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,");
Copy link

@ghost ghost Aug 16, 2017

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.

Copy link
Member Author

@josesimoes josesimoes Aug 16, 2017

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.

Copy link

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 "," ?

Copy link
Member Author

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? 😉

Copy link

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

Copy link
Member Author

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. 😉

Copy link

@ghost ghost Aug 16, 2017

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.

Copy link
Member

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 ?

Copy link
Member Author

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?

Copy link

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Series: STM32xx Everything related specifically with STM32 targets Type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants