Go Down

Topic: New fast digital I/O and Software SPI libraries (Read 8 times) previous topic - next topic

pYro_65

Quote
Embedded programming standards don't have statements like:
Quote
would it not be suitable if users of the code are made fully aware of the behavior.


Agreed, they probably don't. But what they should have is technical documentation specifying all the client needs to know. Reading the documentation is hopefully part of most design standards, certainly in mine anyway. I assume you are pointing out that this expectation isn't always met on large scale systems or projects involving many people.

And as much as I want to argue I guess I can't overcome the fact that someone will eventually skip the important information, causing a bad day.

I'll download libre office so I can view that doc. Might be some good insights in there.

Graynomad

Quote
Nothing really matters with Arduino since it is a case study in bad practice

:)

Here's a PDF of the JSF document for those who don't want to download a DOC

http://www.robgray.com/temp/JSF-AV-rules.pdf

and the similar JPL standard

http://www.robgray.com/temp/JPL_Coding_Standard_C.pdf

As an example of the Arduino code, from digitalWrite()

Code: [Select]
uint8_t port = digitalPinToPort(pin);
...
if (port == NOT_A_PIN) return;


digitalPinToPort() is just a macro that indexes into an array, there is no bounds checking and any non-zero value satisfies the if test. So

Code: [Select]
pin = 1000;
...
digitalWrite(pin, HIGH);


Probably actually works (I don't have any hardware to test it right now) but would almost certainly not do what you expect.

To be fair for what the Arduino is this may be a reasonable trade off between reliability and speed, but we often get "Can I use an Arduino in a commercial product?" style questions and while legally you can, in good conscience I don't think we should advise in the affirmative on technical grounds.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

JaCooke

And what's wrong with the technical ground of Arduino?
first attempts in Arduino support

Graynomad

#8
Aug 14, 2012, 01:32 am Last Edit: Aug 14, 2012, 01:35 am by Graynomad Reason: 1
I'm referring to the lack of defensive coding techniques used in the standard Arduino libraries. My digitalWrite(1000, HIGH); example should not be allowed to execute at run time. The error should be trapped. And IIRC there are many more examples.

I appreciate that error trapping make the program slower and larger and it's not required for the average Arduino user anyway so I'm not having a go at the decisions that were presumably made in this regard when the code was written with the "wearable LED/installation art" audience in mind.

But I don't believe the Arduino libraries should be used in a commercial or otherwise critical application.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

westfw

I assure you that there are many commercial projects that use coding standards no more rigid than the Arduino core.

Go Up