Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.electronics.design > #545524
| From | Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> |
|---|---|
| Newsgroups | sci.electronics.design |
| Subject | Re: Arduino code sources? |
| Date | 2019-06-02 09:39 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <qd05h7$as3$1@dont-email.me> (permalink) |
| References | <pg02fept12fd4h872f8jq590libopp4201@4ax.com> <2bc464da-5bdc-4606-846b-a07b2b35e34e@googlegroups.com> <qctimi$vi5$4@dont-email.me> <ab2c7bed-385d-4dec-b1de-57eecae0e819@googlegroups.com> <xhLIE.27461$NT5.464@fx47.iad> |
On a sunny day (Sun, 2 Jun 2019 17:55:07 +1000) it happened Clifford Heath
<no.spam@please.net> wrote in <xhLIE.27461$NT5.464@fx47.iad>:
>On 2/6/19 8:06 am, John Miles, KE5FX wrote:
>> On Saturday, June 1, 2019 at 3:06:15 AM UTC-7, Cursitor Doom wrote:
>>> On Fri, 31 May 2019 17:02:54 -0700, John Miles, KE5FX wrote:
>>>
>>>> The advice to start with K&R C is OK as far as it goes,
>>>> but it's akin to telling an electronics novice to start with
>>>> vacuum tubes.
>>>
>>> What's wrong with that?
>>
>> For one thing, you'll be outcompeted by people who spent the same amount
>> of time learning modern techniques.
>>
>> For another, people who advocate K&R C are looking through rose-colored
>> glasses to some extent. There is some genuinely crappy code in that
>> book, and some of the decisions made in the early history of C and
>> its standard library have probably cost us hundreds of billions of dollars.
>
>The most costly mistake in the history of programming has to be "errno",
>from Unix. DOS and Windows copied it, more or less.
>
>Recall "Unknown error 0x80000000"? We Unix folk used to laugh, but it's
>just what you get when a call returns -1 or NULL without setting errno.
Probably the programmer screwed up in that case.
Read the documentation for that function if it is in libc.
Lemme state that if you really do not know what is happeing you should not be programming.
(operator overloading in seeplushplush comes to mind)
Why do I NEVER have those problems?
Well I dunno.
What I usually do in C is have a printf() at the start of each function, that can be activated by running the thing
with a command line flag:
my_program -v 1
for level 1 debugging
That printf then prints the function name and arguments.
Like this for example:
char *my_function_do_something(int a, char *b, int *result)
{
int b;
if(verbose)
{
fprintf(stderr, "my_function_do_something(): arg a=%d b=%p result=%p\n", a, b, result);
}
/* parameter check */
if(a < 10) return 0;
if(a > 20) return 0;
if(! b) return 0;
if(! result) return 0;
// do something
if(! calculation(a, &b) ) // calculation will say what is wrong in verbose mode
{
return 0;
}
*result = a * 1234;
if(*result == NAN) // LOL
{
if(verbose)
{
fprintf(stderr "my_function_do_something(): calculation() returned out of range value %d for *result\n", *result);
}
return 0;
}
i(verbose)
{
fprintf(stderr, "my_function_do_something(): returning *result=%d\n", *result);
}
// OK
return 1;
}
called like
if(! my_function_do_something(x, some_string, &a) )
{
return 0;
// could optionally exit here
}
If you put the error report in every function that way,
then you see any problems in verbose mode in a few seconds.
Also you see any silly number mistakes you made.
For errno again check the library documentation.
I have not used a debugger since 1984 or so when I wrote one...
>EPERM: "Permission denied" - What permission was needed? To access what
>operation on what object? - The kernel knew these things, but didn't say.
>
>ENOENT: "No such file or directory" - Well which is it, a file or a
>directory? Perchance you'd like to tell me which one?
>
>Those are just the first two errors in errno. It doesn't get any better.
>Windows has literally millions of such error codes, because they break
>it up as a 16 bit value under a 12-bit "facility code".
>
>This is the root of *most* user frustration and time lost with computer
>systems. We expect things to go wrong, but we also expect to be told
>what, and why, and how we can fix it.
>
>Clifford Heath.
libc.info is good.
I you have never heard of it (it should be on your Linux system) then try this old version in text form:
http://www.panteltje.com/pub/libc.info.txt
What are you going to do without it?
Networking? memory management? math? threads?
All C library functions are treated there, many with examples.
It is my C programming reference, I just use the text editor search function on it.
Maybe the extra fprintf(stderr is more work.
But it stil saves time.
Especialy when you write code incrementally.
For more complex problems I often start wih text
/* do this */
/* do that */
/* do something different */
and fill in the code later.
Turing
its simple
seeplusplush is a crime against humanity.
There were days not even the seeplushplush compiler writers could agree what the syntax meant.
Did not get better, now NOBODY knows it :-)
Back to sci.electronics.design | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Arduino code sources? Terry Pinnell <me@somewhere.invalid> - 2019-05-31 11:48 +0100
Re: Arduino code sources? Cursitor Doom <curd@notformail.com> - 2019-05-31 11:40 +0000
Re: Arduino code sources? Lasse Langwadt Christensen <langwadt@fonz.dk> - 2019-05-31 05:32 -0700
Re: Arduino code sources? Winfield Hill <hill@rowland.harvard.edu> - 2019-05-31 06:54 -0700
Re: Arduino code sources? bitrex <user@example.net> - 2019-05-31 10:46 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-05-31 10:47 -0400
Re: Arduino code sources? Lasse Langwadt Christensen <langwadt@fonz.dk> - 2019-05-31 07:49 -0700
Re: Arduino code sources? Peter Percival <peterxpercival@hotmail.com> - 2019-06-12 13:41 +0100
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-12 21:48 -0400
Re: Arduino code sources? Peter Percival <peterxpercival@hotmail.com> - 2019-06-13 17:46 +0100
Re: Arduino code sources? George Herold <gherold@teachspin.com> - 2019-05-31 07:45 -0700
Re: Arduino code sources? bitrex <user@example.net> - 2019-05-31 11:37 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-05-31 11:39 -0400
Re: Arduino code sources? Terry Pinnell <me@somewhere.invalid> - 2019-05-31 18:13 +0100
Re: Arduino code sources? Ralph Mowery <rmowery28146@earthlink.net> - 2019-05-31 15:07 -0400
Re: Arduino code sources? "John Miles, KE5FX" <jmiles@gmail.com> - 2019-05-31 17:02 -0700
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-01 04:57 +0000
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-01 01:11 -0400
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-01 05:56 +0000
Re: Arduino code sources? "John Miles, KE5FX" <jmiles@gmail.com> - 2019-05-31 23:34 -0700
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-01 07:34 +0000
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-01 06:39 -0400
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-01 07:50 +0100
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-01 07:17 +0000
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-01 06:45 -0400
Re: Arduino code sources? DecadentLinuxUserNumeroUno@decadence.org - 2019-06-01 11:13 +0000
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-01 21:06 +1000
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-01 12:33 +0100
Re: Arduino code sources? DecadentLinuxUserNumeroUno@decadence.org - 2019-06-01 12:03 +0000
Re: Arduino code sources? Lasse Langwadt Christensen <langwadt@fonz.dk> - 2019-06-01 05:15 -0700
Re: Arduino code sources? DecadentLinuxUserNumeroUno@decadence.org - 2019-06-02 01:48 +0000
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-01 11:26 -0400
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-01 19:03 +0100
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-01 19:56 -0400
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-02 01:13 +0100
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-02 20:09 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-02 20:16 -0400
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-03 11:10 +1000
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-02 22:26 -0400
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-03 12:37 +1000
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-02 23:14 -0400
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-03 14:30 +1000
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-03 08:46 +0100
Re: Arduino code sources? DecadentLinuxUserNumeroUno@decadence.org - 2019-06-03 11:58 +0000
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-01 17:18 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-01 17:24 -0400
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-01 20:08 -0400
Re: Arduino code sources? Lasse Langwadt Christensen <langwadt@fonz.dk> - 2019-06-01 17:14 -0700
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-01 20:26 -0400
Re: Arduino code sources? "Rodney Pont" <mlist4@infohit.me.uk> - 2019-06-01 15:19 +0100
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-02 17:42 +1000
Re: Arduino code sources? "John Miles, KE5FX" <jmiles@gmail.com> - 2019-06-02 01:53 -0700
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-02 22:46 +1000
Re: Arduino code sources? Dennis <dennis@none.none> - 2019-06-01 09:43 -0500
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-01 11:30 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-03 00:00 -0400
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-03 05:52 +0000
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-03 11:33 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-03 11:41 -0400
Re: Arduino code sources? pcdhobbs@gmail.com - 2019-06-03 16:29 -0700
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-04 02:14 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-04 02:27 -0400
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-03 08:50 +0100
Re: Arduino code sources? krw@notreal.com - 2019-06-03 19:12 -0400
Spot the app note error was Arduino code sources? Don Kuenz, KB7RPU <g@crcomp.net> - 2019-06-04 16:03 +0000
Re: Spot the app note error was Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-04 13:17 -0400
Re: Spot the app note error Don Kuenz <g@crcomp.net> - 2019-06-04 21:47 +0000
Re: Spot the app note error was Arduino code sources? Don Kuenz <g@crcomp.net> - 2019-06-08 18:34 +0000
Re: Spot the app note error was Arduino code sources? bitrex <user@example.net> - 2019-06-04 15:30 -0400
Re: Spot the app note error Don Kuenz, KB7RPU <g@crcomp.net> - 2019-06-04 21:48 +0000
Re: Spot the app note error Winfield Hill <winfieldhill@yahoo.com> - 2019-06-04 15:51 -0700
Re: Spot the app note error Don Kuenz, KB7RPU <g@crcomp.net> - 2019-06-04 23:28 +0000
Re: Spot the app note error Don Kuenz, KB7RPU <g@crcomp.net> - 2019-06-04 23:40 +0000
Re: Spot the app note error Winfield Hill <winfieldhill@yahoo.com> - 2019-06-04 17:21 -0700
Re: Spot the app note error Don Kuenz, KB7RPU <g@crcomp.net> - 2019-06-05 01:13 +0000
Re: Spot the app note error bitrex <user@example.net> - 2019-06-04 23:02 -0400
Re: Spot the app note error bitrex <user@example.net> - 2019-06-04 23:05 -0400
Re: Spot the app note error Winfield Hill <winfieldhill@yahoo.com> - 2019-06-05 01:08 -0700
Re: Spot the app note error bitrex <user@example.net> - 2019-06-06 00:22 -0400
Re: Spot the app note error bitrex <user@example.net> - 2019-06-06 00:27 -0400
Re: Spot the app note error Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-05 22:48 -0400
Re: Spot the app note error Winfield Hill <winfieldhill@yahoo.com> - 2019-06-07 13:35 -0700
Re: Spot the app note error Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-07 20:44 -0400
Re: Arduino code sources? Cursitor Doom <curd@notformail.com> - 2019-06-01 09:57 +0000
Re: Arduino code sources? Cursitor Doom <curd@notformail.com> - 2019-06-01 10:06 +0000
Re: Arduino code sources? "John Miles, KE5FX" <jmiles@gmail.com> - 2019-06-01 15:06 -0700
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-02 03:26 +0000
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-02 17:55 +1000
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-02 09:39 +0000
Re: Arduino code sources? DecadentLinuxUserNumeroUno@decadence.org - 2019-06-02 11:02 +0000
Re: Arduino code sources? Cursitor Doom <curd@notformail.com> - 2019-06-02 11:43 +0000
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-02 22:57 +1000
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-02 15:05 +0000
Re: Arduino code sources? Cursitor Doom <curd@notformail.com> - 2019-06-02 17:00 +0000
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-03 10:07 +1000
Re: Arduino code sources? Jasen Betts <jasen@xnet.co.nz> - 2019-06-03 00:55 +0000
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-03 05:22 +0000
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-03 11:00 +1000
Re: Arduino code sources? Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> - 2019-06-03 05:21 +0000
Re: Arduino code sources? Clifford Heath <no.spam@please.net> - 2019-06-03 17:15 +1000
Re: Arduino code sources? Cursitor Doom <curd@notformail.com> - 2019-06-02 15:23 +0000
Re: Arduino code sources? Rheilly Phoull <rheilly@bigslong.com> - 2019-06-01 08:13 +0800
Re: Arduino code sources? sdy <sdeyoreo@hotmail.com> - 2019-05-31 18:38 -0700
Re: Arduino code sources? Terry Pinnell <me@somewhere.invalid> - 2019-06-01 11:45 +0100
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-01 12:36 +0100
Re: Arduino code sources? Terry Pinnell <me@somewhere.invalid> - 2019-06-01 16:04 +0100
Re: Arduino code sources? Lasse Langwadt Christensen <langwadt@fonz.dk> - 2019-06-01 04:38 -0700
Re: Arduino code sources? Phil Hobbs <pcdhSpamMeSenseless@electrooptical.net> - 2019-06-01 11:32 -0400
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-01 19:05 +0100
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-02 23:52 -0400
Re: Arduino code sources? Tom Gardner <spamjunk@blueyonder.co.uk> - 2019-06-03 08:53 +0100
Re: Arduino code sources? Ralph Mowery <rmowery28146@earthlink.net> - 2019-06-01 11:26 -0400
Re: Arduino code sources? "Rodney Pont" <mlist4@infohit.me.uk> - 2019-06-01 15:11 +0100
Re: Arduino code sources? Terry Pinnell <me@somewhere.invalid> - 2019-06-01 16:20 +0100
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-02 23:08 -0400
Re: Arduino code sources? bitrex <user@example.net> - 2019-06-02 23:40 -0400
csiph-web