Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: File class documentation - where is it ? on: February 04, 2014, 08:10:21 am
Did you look in File.cpp in the SD directory?

entry.name() returns a pointer to a string. strcpy() or strdup() depending on whether you have allocated space already, or not.

Hi Paul,
     Thanks for the reply !

    I have tried
 
Code:


    char* pBuff;
     pBuff = entry.name;

    ... but I get a compiler error on the last line    
          "argument of type 'char* (File:smiley()' does not match 'char*'  "
                 Hence my " problem "/ confusion !!

STUPID ME !!   Left off the () after " entry.name"  !!   It's always the simple things !!!!

Thanks all for sharing my suffering/ stupidity !!!
2  Using Arduino / Programming Questions / Re: File class documentation - where is it ? on: February 04, 2014, 07:55:28 am
Did you look in File.cpp in the SD directory?

entry.name() returns a pointer to a string. strcpy() or strdup() depending on whether you have allocated space already, or not.

Hi Paul,
     Thanks for the reply !

    I have tried
 
Code:
    char* pBuff;
     pBuff = entry.name;

    ... but I get a compiler error on the last line   
          "argument of type 'char* (File:smiley()' does not match 'char*'  "
                 Hence my " problem "/ confusion !!
3  Using Arduino / Programming Questions / File class documentation - where is it ? on: February 04, 2014, 07:27:01 am
Hello,  I'm trying to use the File class and really need some documentation.  I'm using the SD example code in ListFiles sketch
Code:
         File entry =  dir.openNextFile();
        if (! entry)
        {
            // no more files
             Serial.println("**nomorefiles**");
            break;    // Finished !!
     }
     
     Serial.println(entry.name());

However, I want to copy the file name returned by entry.name() rather than print it to the Serial monitor but can't find any documentation on using the class File.

Any help would be appreciated
4  Using Arduino / Programming Questions / Re: sprintf problem on: January 09, 2014, 07:02:27 am
Quote
A bit messy,but it works !!
Until you try that with flItem = 1.05.

Change the format specifiers to %d.%02d, so that there are always exactly 2 digits after the decimal point.

You beat me to it - just found that !!   (Well spotted)
5  Using Arduino / Programming Questions / Re: sprintf problem on: January 09, 2014, 05:59:58 am
I've got round the problem ....
Code:
    // sprintf(g_chMsg,"Float flItem = %5.2lf  <",flItem);
    byte byIntPart = (byte)flItem;
    byte byFractPart = (byte)(flItem - byIntPart)*100;
    sprintf(g_chMsg,"Zone %d temperature is %d.%d deg C", byZoneNum, byIntPart,byFractPart);
      A bit messy,but it works !!
6  Using Arduino / Programming Questions / Re: sprintf problem on: January 09, 2014, 03:17:11 am
sprintf doesn't work with float.
I assume that you mean that it doesn't work with Arduino C ?  (asit does in "normal" C/C++)
If so, that is most anoying  !!

Thanks for your helpanyway !
7  Using Arduino / Programming Questions / sprintf problem on: January 09, 2014, 03:03:57 am
I am trying to format a string with a floating point specifier/value asbelow
Code:
    float flVal = 23.468;
     sprintf(buff,"The floating pointvalue is %3.2f", flVal);
     Serial.println(buff);

    The result that i get is a '?' where the value shoul be.

    Am I using the wrong specifier, and if so what is it ??

   Many thanks !
8  Using Arduino / Project Guidance / Re: NAS disk access by Ethernet Arduino ?? on: October 13, 2013, 03:38:41 pm
Hi Peter,   Many thanks for your comments - very helpful and this encourages me to investigate further.  I want to avoid an intermediate PC, as it seems like overkill to keep it powered up 24/7 as the files always need to be available for access in the proposed project.   The NAS involved is quite sophisticated, so hopefully it will enable one of the solutions that you mention - I shall start looking into that ..... !!   Thanks once again !
9  Using Arduino / Project Guidance / NAS disk access by Ethernet Arduino ?? on: October 12, 2013, 03:04:36 pm
Can anyone help me with this ?
I want to produce an Arduino project where the sketch will need the contents of files resident on a Network Attached Storage (NAS) device.  Is there any way that this can be achieved simply ??  (Sorry - I don't know a lot about the Ethernet Arduino, but I haven't seen any references to it operating in this way)
   Any help will be greatly appreciated !
10  Using Arduino / Programming Questions / Re: Problem with Serial.print formatting on: March 29, 2013, 02:21:01 pm
If you don't want sign extension, don't use signed datatypes

Ahhhh !  Had forgotten that char defaulted to signed !  (Distracted by the hex representation)  All fixed !  Ta !
11  Using Arduino / Programming Questions / Re: Problem with Serial.print formatting on: March 29, 2013, 11:42:03 am
Quote
Looks like you hit the nail on the head.
   
     So what if I don't want sign extension ...... ?



12  Using Arduino / Programming Questions / Problem with Serial.print formatting on: March 29, 2013, 11:32:40 am
I have written a bit of diagnostic code to check out some added hardware to my Arduino Uno.   Having written some random data to the added hardware (memory), I read it back and compare it against what was written.  However, the serial monitor "appears" to be adding a byte of FF for negative hex numbers.
Here is a code snippet-
          Serial.print("Data compare error at location  "); 
          Serial.print(j*512+i,DEC);
          Serial.print(" Read data = ");
          sprintf(chMsg,"%02X",chDataR);
          Serial.print(chMsg);
          Serial.print("\t");
   
          Serial.print(" Write data = ");
          sprintf(chMsg,"%02X",chDataW);
          Serial.print(chMsg);
          Serial.print(" \n");   

and here is a bit of serial monitor output to show the problem (lines 6 and 7):-

------- End of block  44 ---------
Time for 512 byte block = 6816 microseconds.  (13 uSecs per byte.)
------- End of block  45 ---------
Time for 512 byte block = 6816 microseconds.  (13 uSecs per byte.)
Data compare error at location  23890 Read data = 0A    Write data = 45
Data compare error at location  23891 Read data = FFA1    Write data = 50
Data compare error at location  23892 Read data = 3E    Write data = FF9F
.....

Any ideas about why the serial monitor is introducing this "sign extension" ??
Many thanks !
13  Using Arduino / Project Guidance / Re: Running out on pins on my Uno ...... !! on: January 27, 2013, 05:19:10 pm
I suspect that this topic has arisen before !!  (Apologises in advance !!)

I'd like to multi-purpose the pins in my current Arduino project.  In essence, can I define a pin TWICE and safely use that definition within it's own "enviroment"

e.g.

int pinPP_nAddrTag = 12;        // Parallel port nAddrTag
int pinLED = 12;                    // The output LED pin (Also pinPP_nAddrTag)

In Setup()
  pinMode(pinPP_nAddrTag, INPUT);
  pinMode(pinLED, OUTPUT);

Question 1 :  
     Is the attribute of INPUT specified in pinMode associated with the variable pinPP_nAddrTag or with pin 12 ??

As it says it is 'pinMode'; it acts on the pin. In your example code you set Pin 12 to INPUT and then you set it to OUTPUT. Therefore it is no longer an input. You need to be careful what you are doing here as you could damage the pin. Let's say you thought it was an input and set it high; that would turn the pullup resistor on, and you'd be expecting something to pull that pin low, with perhaps a direct short to Ground, against the pullup. If you did that when actually your pin was an output then you could short the pin to ground, exceeding it's current rating and destroy it.

Another way of looking at this is as follows ....

In function 1:
       digitalWrite(pinLED, HIGH);

In function  2:
       int iDataRead;
       iDataRead = digitalRead(pinPP_nAddrTag);

Question 2:
       Should I use pinMode(....) in the above functions to establish whether INPUT or OUTPUT) ?

It doesn't matter, you can't use it in both modes simultaneously. If you use it as an output first in Function1 then as soon as you set it to an INPUT it will go high impedance and your LED will light only dimly.

OUTPUT is a Low Impedance state
INPUT is a High Impedance state

Hopefully, you will be understand what I DON'T understand (or what I need reassurance on !!!)

Thanks in advance !

If you were just using it to send a signal then you could manage it's state and use it for both input and output consecutively. That's exactly how something like the I2C bus works but, you can't keep an output high and driven if you're going to change to input. If you had some way of latching the signal out so it only needed a momentary high then you could do so and then re-use the pin.

It's safer just to use one pin for one thing unless you fully understand the limitations.

Hi,
   I think that you have confirmed my suspicions.   (It may SEEM obvious, but I wanted to be CERTAIN that pinMode set the attributes of the PIN and not the VARIABLE associated with the pin)

   Can you confirm that multiple variables can be defined for a pin (so that the name is relevant to the environment).  I do appreciate that NOTHING can be assumed (now) about whether the pin is inbound or outbound, and so you would have to use pinMode on entry to that environment.   I realise that care would need to be taken, but when you run out of pins, you have to start exploring these things !

    Thanks for your help !!
14  Using Arduino / Project Guidance / Running out on pins on my Uno ...... !! on: January 27, 2013, 01:56:34 pm
I suspect that this topic has arisen before !!  (Apologises in advance !!)

I'd like to multi-purpose the pins in my current Arduino project.  In essence, can I define a pin TWICE and safely use that definition within it's own "enviroment"

e.g.

int pinPP_nAddrTag = 12;        // Parallel port nAddrTag
int pinLED = 12;                    // The output LED pin (Also pinPP_nAddrTag)

In Setup()
  pinMode(pinPP_nAddrTag, INPUT);
  pinMode(pinLED, OUTPUT);

Question 1 :  
     Is the attribute of INPUT specified in pinMode associated with the variable pinPP_nAddrTag or with pin 12 ??

Another way of looking at this is as follows ....

In function 1:
       digitalWrite(pinLED, HIGH);

In function  2:
       int iDataRead;
       iDataRead = digitalRead(pinPP_nAddrTag);

Question 2:
       Should I use pinMode(....) in the above functions to establish whether INPUT or OUTPUT) ?


Hopefully, you will be understand what I DON'T understand (or what I need reassurance on !!!)

Thanks in advance !

15  Using Arduino / Installation & Troubleshooting / Re: Chip reversal !!! on: January 23, 2013, 04:44:26 pm
That's great  !!  Thank you all for helping me out with your advice !  smiley
Pages: [1] 2