Show Posts
Pages: 1 ... 70 71 [72] 73 74 ... 112
1066  Development / Suggestions for the Arduino Project / Re: Benevolent dictator or democracy? on: July 25, 2012, 09:49:52 am
I really like Constantin's analysis of the situation.

After more thought, I think a first step to democracy should be to "Petition the King" for the freedom to setup groups like Constantin described.

For a petition to be effective, you need support from people that matter to the King. 

In the case of the Magna Carta it was feudal barons, not little people.

I am not sure who the equivalent of barons are for Arduino, maybe Arduino vendors and people like Paul Stoffregen with products like Teensy.

Any suggestions on how to ask the King for freedom?
1067  Using Arduino / Storage / Re: undocumented classes Sd2Card, SdVolume and SdFile on: July 25, 2012, 07:49:07 am
The Arduino group doesn't really want you to use these classes.  That's why they developed the SD.h wrapper.

If you want to use these classes you should probably use SdFat directly.  There is Doxygen html documentation for these classes with the SdFat library here
1068  Development / Suggestions for the Arduino Project / Re: Benevolent dictator or democracy? on: July 25, 2012, 07:43:17 am
BSD Unix is a possible model.  I was at UC Berkley in a computer science research group when BSD evolved.

Ken Thompson and Dennis Ritchie developed Unix at AT&T's Bell Laboratories in the early 1970s.  In January 1974 Professor Bob Fabry obtained a Version 4 tape and it was installed on a PDP-11/45 at UC Berkeley.

AT&T corporation  saw that Unix was successful  and dealing with them became more difficult.  

A number of extensions, fixes, and improvements were developed by users of Unix.  Bill Joy collected these and released a tape called first Berkeley Software Distribution (1BSD).  This was an add-on to Sixth Edition Unix from AT&T.

This process of support evolved until DARPA provided funding to make 4BSD a free open source OS for computer science research.

Development of BSD Unix was guided by an amazing committee:
To guide the design of 4.2BSD DARPA formed a"steering committee" consisting of Bob Fabry, Bill Joy and Sam Leffler from UCB, Alan Nemeth and Rob Gurwitz from BBN, Dennis Ritchie from Bell Labs, Keith Lantz from Stanford, Rick Rashid from Carnegie-Mellon, Bert Halstead from MIT, Dan Lynch from ISI, and Gerald J. Popek of UCLA. The committee met from April 1981 to June 1983.

User support from the Arduino group is non-existent.  A first step could be to collect fixes and improvements in a well known place.  

This would be along the lines of what Paul Stoffregen is doing, not forking the project.

Some open structure needs to be setup to screen and organize submissions so users can easily find and install what they need.

Another step could be a discussion space as pico mentioned where the main topic is how to organize an open user support group.

FreeBSD evolved from the UC work.  This is a key statement about the organization of FreeBSD:
The FreeBSD Core Team constitutes the project's "Board of Directors", responsible for deciding the project's overall goals and direction as well as managing specific areas of the FreeBSD project landscape. The Core Team is elected by the active developers in the project.

So to have a say, vote, you must contribute.
1069  Development / Suggestions for the Arduino Project / Benevolent dictator or democracy? on: July 24, 2012, 05:36:28 pm
Why is the Arduino group organized as a benevolent dictatorship and not in a more open democratic way like Debian

The current organization seems to lead to many foul-ups like this,115552.msg869572.htm where Paul Stoffhegan submitted a fix to a serious bug but the fix was not properly handled.

Many of us waste a lot of time because of mysterious events like this.

A more open organization with elections for leaders and a technical board might provide better support for Arduino users.

Even more important, this would provide a better path for development of new features in future releases.
1070  Using Arduino / Storage / Re: Data Logger SD, String stops earlier than expected on: July 23, 2012, 06:19:13 pm
Gasp!  The problem appears to be in free(),115552.msg869983.html#msg869983.
1071  Development / Suggestions for the Arduino Project / Re: String corrupts the heap and crashes on: July 23, 2012, 06:16:39 pm
Now you see why malloc/heap is not used in serious embedded projects.  This sort of thing happens over and over.

I agree with Graynomad, one could consider allocation of memory at start-up as in the JSF standard.

I never use dynamic memory in my libraries or applications but waste lots of time chasing bugs that are reported in my software that turnout to be due to dynamic memory.

In the future I simply won't look for bugs if an application uses dynamic memory.  Well, maybe I will look for obvious stuff.

This was good for a laugh, failure of free, wow. 

I have more respect for the decision of the real embedded system pros when they forbid use of dynamic memory in standards for critical systems.
1072  Development / Suggestions for the Arduino Project / Re: String corrupts the heap and crashes on: July 23, 2012, 03:44:35 pm
In my opinion shot-in-dark things like allocate 10 or 20 extra bytes are the wrong way to fix bugs like this.

You then stand the chance of making it sill happen but less often.

There are lots of cases where this type of fix was used in safety critical systems with horrible outcome.  Then you trust the system because it seems to work but the bug is still there.

Paul usually tries to get the Arduino group to accept his fixes.  I hope the Arduino group would apply a fix if Paul submitted it.

1073  Development / Suggestions for the Arduino Project / Re: String corrupts the heap and crashes on: July 23, 2012, 01:57:09 pm
The bug is really ugly since the String calls complete successfully but the heap has been destroyed.  The crash often happens in some other part of the program much later.

I looked at String and thought about modifying it with traps like PaulS suggested but soon realized there are lots more things to check.

I decided finding bugs in String is above my pay grade.

Besides, I was trained to never use the heap/malloc in embedded systems.  Most coding standards for critical aerospace systems and motor vehicle coding standards like MISRA have statements like this:
MISRA C++ rule 18-4-1, dynamic heap memory allocation cannot be used.
1074  Development / Suggestions for the Arduino Project / String corrupts the heap and crashes on: July 23, 2012, 11:50:37 am
This example, which crashes before printing "Done", demonstrates a serious bug in String.
#include <MemoryFree.h>
void setup() {
void loop() {
  int n = 0;
  while(n <=100) {
    int u = 20*n;
    int v = 30*n;
    String str = String(n) + ", " + String(u) + ", " + String(v) + ", " + String(freeMemory());
The output looks like this and the value of freeMemory() in the last column indicates a corrupt heap.
0, 0, 0, 1740
1, 20, 30, 1738
2, 40, 60, 13048
3, 60, 90, 24358
4, 80, 120, -29870
5, 100, 150, -17536
6, 120, 180, -3921
7, 140, 210, 10462
8, 160, 240, 23054
9, 180, 270, -29122
-----crash and restart here---

The bug is from a larger program here,115451.0.html
1075  Using Arduino / Storage / Re: Data Logger SD, String stops earlier than expected on: July 23, 2012, 09:43:15 am
Looks like String corrupts the heap.  I added freeMemory() to a simplified version of the program and the result makes no sense.  The problem seems to be with the free list.

Here is the simple program that fails:
#include <MemoryFree.h>
void setup() {

void loop() {
  int id = 0;
  while (id <= 20)
    //Main battery Voltage
    int voltage = 20*id;  //analogRead(1);
    //Sense Resistance/ Current Drawn
    int current = 30*id;  //analogRead(2);

    //Create Data string for storing to SD card 
    String dataString = String(id)+ ", " +String(voltage)+", "+ String(current)+", "+String(freeMemory());

    //Increment ID number

Here is the printout.  The last column is the value returned by freeMemory() which is nonsense.
0, 0, 0, 1742
1, 20, 30, 1740
2, 40, 60, 13050
3, 60, 90, 24360
4, 80, 120, -29868
5, 100, 150, -17534
6, 120, 180, -3919
7, 140, 210, 10464
8, 160, 240, 23056
9, 180, 270, -29120
If I comment out this line in freeMemory
//    free_memory += freeListSize();
I get this
0, 0, 0, 1742
1, 20, 30, 1703
2, 40, 60, 1703
3, 60, 90, 1703
4, 80, 120, 1703
5, 100, 150, 1703
6, 120, 180, 1703
7, 140, 210, 1703
8, 160, 240, 1703
9, 180, 270, 1703
So a bug in String must write over the free list.
1076  Development / Other Software Development / Re: Fast digital I/O and software SPI with C++ templates on: July 21, 2012, 06:34:29 pm
FastDigitalIO has evolved into DigitalPin,86931.0.html.

You must use constant pin numbers with any of the fast digital I/O libraries.  That's the only way the compiler can optimize to the fast sbi and cbi instructions.  This means you may need to use templates to use a fast I/O library in another library.

I will include an example software SPI library based on DigitalPin in the next version of DigitalPin.

I am using DigitalPin and SoftSPI in the 20120719 version of SdFat The files for DigitalPin and SoftSPI are in the utility folder of SdFat.  I will soon post these files as a standalone library.
1077  Development / Other Software Development / Re: Fast alternative to digitalRead/digitalWrite on: July 21, 2012, 01:47:40 pm
I can't improve the speed since functions like pin.high() and pin.low() compile to a single sbi or cbi instruction for low address I/O ports.  All ports on the 328 and ports A-G on the Mega are low address.  These instructions execute in 2 cycles or 125 ns on a 16 MHz cpu.

I have added software SPI which runs at about 2 MHz.  This library supports all SPI modes for MSB first.  It would be easy to add an option for LSB first.

I have not posted the latest version as a standalone library.  The latest version of DigitalPin with SoftSPI is used in the new 20120719 version of SdFat.  The files DigitalPin.h and SoftSPI.h are in the SdFat/utility folder and SdFat is here

I have also written a software I2C library based on the DigitalPin library that runs at 400 kHz.  I plan to post this I2C library soon.
1078  Using Arduino / Storage / Re: SdFat update on: July 21, 2012, 09:13:11 am
SdFat has a function, rmRfStar(), that will clean an SD.  Here is the documentation:
bool SdBaseFile::rmRfStar()    

Recursively delete a directory and all contained files.

This is like the Unix/Linux 'rm -rf *' if called with the root directory hence the name.

Warning - This will remove all contents of the directory including subdirectories. The directory will then be removed if it is not root. The read-only attribute for files will be ignored.

    This function should not be used to delete the 8.3 version of a directory that has a long name.

    The value one, true, is returned for success and the value zero, false, is returned for failure.

Here is an example sketch that will delete all except the root directory:
#include <SdFat.h>
SdFat sd;

void setup() {
  Serial.println("Type any character to delete all files");
  while ( <= 0) {}
  if (!sd.begin()) sd.initErrorHalt();
  // list all files;
  // sd.vwd() is root, working directory for volume
  // remove all files and directories in root
  Serial.println("---------- rmRfStar()");;
void loop() {}
Here is output from the sketch using an SD with two directories and a file.
Type any character to delete all files
---------- rmRfStar()

1079  Using Arduino / Storage / Re: SdFat.h incompatible with SD.h? on: July 20, 2012, 09:26:01 am
If you mean file.available(), SdFat does not provide available() since this function does not always provide the correct result in SD.h. The problem is available() is declared as an int in the Stream class.  Type int is limited to 32767 bytes but files can be much larger, up to 4294967295 bytes.

You can use the following expression in SdFat:
 uint32_t bytesLeft;
  bytesLeft = file.fileSize() - file.curPosition();

Too get the correct result with SD.h use this expression instead of available():
 uint32_t bytesLeft;
  bytesLeft = file.size() - file.position();

1080  Using Arduino / Storage / Re: SD card file write is skipping data on: July 20, 2012, 09:12:14 am
SD.begin() initializes the SD card, mounts the FAT volume, and clears any unwritten data in internal buffers.

Calling it in loop discards a lot of data and may cause file system corruption.  SD.h was not designed to call SD.begin() multiple times.  SD.h is a wrapper for an old version of SdFat.  The wrapper has bugs that prevent multiple calls from always working.

SdFat allows multiple calls to begin/init if all files are closed first.  This allows one SD card to be removed and another SD card to be inserted.
Pages: 1 ... 70 71 [72] 73 74 ... 112