Show Posts
Pages: 1 [2] 3 4 ... 20
16  Forum 2005-2010 (read only) / Troubleshooting / Re: real string functions? on: April 23, 2006, 05:40:21 am
you're totally right.

sorry for upsetting you. the examples were just chosen to simplify the problem.

of course i won't send "arduino, please turn all lights off exept no. 12". what i was trying to do is letting arduino understand and handle ESC sequences. a maximum of 3 characters at the moment.

after all, understanding (i'm not there yet) strings and pointers, seemed a good start for understanding why my programs keep crashing :-)
it works now.

the problem was that i  tried to reset the string with: myString="";

or even:  myString="\0";  // for zero termination

both didn't work.

strcpy(myString, "");

did the trick.
thank you, kuk






17  Forum 2005-2010 (read only) / Troubleshooting / Re: real string functions? on: April 21, 2006, 01:24:26 pm
hmm, can i add a single char to an existing string?

like

char *mystr = "hello worl";
char singleChar = "d";

*mystr = strcat(*mystr , ch):

printString(*mystr);

or similar?
18  Forum 2005-2010 (read only) / Troubleshooting / Re: real string functions? on: April 21, 2006, 07:41:22 am
hey thank you very much.

can't test it at the moment, but your answer seems to solve all the problems i encountered. nice to know that about string comparism in c.

best,
kuk
19  Forum 2005-2010 (read only) / Troubleshooting / real string functions? on: April 20, 2006, 06:41:51 pm
hello,

for a program i need to listen on the serial port and add all incoming characters to a string. if arduino receives a "carriage return" it shall compare it to other strings to see if the received string is a "command". then it should reset the string to "" (empty string).

the string examples in the tutorials don't work for me, because they all add letters in "while"-loop directly reading letters from the serial port. in my case, it might happen that there is a very long pause between the different characters. so i would exit the while-loop before the command is complete.

i looked into string manipulation in c, but wasn't successful.

basically i need something like this:
Code:
byte command[];

void handleIncomingByte( byte aCharacter) {
  if( aLetter=="13" ){   //if aLetter is a carriage return our string is complete
     //do some comparism
     if(command=="light"){
        //do something
     }

     //and important: reset command variable
     command="";
    
  }else{
      //add aCharacter to command
     command[strlen(command)]= aCharacter;
  }
}


both the string comparism and the resetting the string don't work.
what am i missing?
20  Forum 2005-2010 (read only) / Troubleshooting / Re: RFID with Arduino on: March 31, 2006, 04:17:15 am
what do you mean by launch? will they be for sale as an add-on or do you mean a tutorial will be available?

(just because shipping is quite expensive. thus i would wait for the rfid reader to be available before ordering a few boards for friends of mine. )
21  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: delayMicroseconds(0) on: November 15, 2007, 10:57:39 am
i agree, now that someone found out we should keep this in mind, i just meant to underline that.
peace,kuk
22  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: delayMicroseconds(0) on: November 14, 2007, 01:05:59 pm
i guess hard-coding a zero doesn't make sense here. still there's a big chance to invoke delayMicroseconds(0) if the parameter is dynamic, like "howManyButtonsPressed" to make it simple.
23  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: delayMicroseconds(0) on: October 12, 2007, 04:30:28 pm
yeah  smiley

thank you.
24  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: delayMicroseconds(0) on: October 12, 2007, 04:23:06 pm
hi mellis,
why is that? i'd really like to see where this is happening. could you briefly explain the function to help me get it?

25  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: delayMicroseconds(0) on: October 12, 2007, 04:12:06 pm
not sure if it matters, but are you running this on an atmega8 or 168 ?

your test output might be wrong though. this is the function definition of delayMicroseconds takne from libs/targets/arduino/wiring.c:

Code:
/* Delay for the given number of microseconds.  Assumes a 16 MHz clock.
 * Disables interrupts, which will disrupt the millis() function if used
 * too frequently. */
void delayMicroseconds(unsigned int us)
{
      uint8_t oldSREG;

      // calling avrlib's delay_us() function with low values (e.g. 1 or
      // 2 microseconds) gives delays longer than desired.
      //delay_us(us);

      // for a one-microsecond delay, simply return.  the overhead
      // of the function call yields a delay of approximately 1 1/8 us.
      if (--us == 0)
            return;

      // the following loop takes a quarter of a microsecond (4 cycles)
      // per iteration, so execute it four times for each microsecond of
      // delay requested.
      us <<= 2;

      // account for the time taken in the preceeding commands.
      us -= 2;

      // disable interrupts, otherwise the timer 0 overflow interrupt that
      // tracks milliseconds will make us delay longer than we want.
      oldSREG = SREG;
      cli();

      // busy wait
      __asm__ __volatile__ (
            "1: sbiw %0,1" "\n\t" // 2 cycles
            "brne 1b" : "=w" (us) : "0" (us) // 2 cycles
      );

      // reenable interrupts.
      SREG = oldSREG;
}

i did not get into it too deep. but the lines
if (--us == 0)
            return;

(BTW: what are the two minus doing there?)
look as if they'd serve a close to zero delay. on the other hand, your real short delays (1µs) might disable interrupts to often which affects the millis() function. see the note at the beginning.

still it would be cool to get a real answer to your question.

26  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Request: bootloader options for brownout detec on: September 10, 2008, 04:16:24 am
PS: i'm using avr studio on a friends PC to burn the bootloaders. so i can't tell about the correct fuse settings for the BOD levels on the AtMEGA128 now.
27  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Request: bootloader options for brownout detec on: September 10, 2008, 04:12:49 am
same here. no more lost bootloaders or corrupt programs since enabling BOD on my 168's. i must say that i'm mostly running them from just 4 AA rechargables without a regulator. so lost bootloaders was a huge issue for me :-)

since this problem mostly appeared with my own creations, i believe BOD is disabled by default just because it's not needed in normal(PLUS) use, with a proper designed board. the only disadvantage of brownout detection i can imagine , would be unwanted resets in otherwise uncritical situations.
28  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Open multiple sketches for editing on: January 30, 2008, 07:24:48 am
Quote
 It's still not clear whether or not each window / sketch should have its own serial port setting and serial monitor.
hi david,
i now remember that you mentioned that you're working on it. please excuse my ignorance... concerning the serial port: as for copy and paste the port wouldn't matter, and i was originally assuming that one was working on a single project most of the time.
still, "multi-board projects" could become more popular with people starting to explore SPI, one-wire and stuff.
would it be hard to to save board and port settings in a sketch rather than in the application settings? i'm thinking of something like two pull-down menus at the top of each window.

best, kuk
29  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Open multiple sketches for editing on: January 29, 2008, 10:52:53 am
let me second this. i'm slowly getting the concept of how tabs are supposed to be used for includes, but copy and paste really is not easy as it is.


30  Forum 2005-2010 (read only) / Bugs & Suggestions / Re: Get a mail for every topic I reply to? on: January 14, 2008, 06:42:16 am
hi eberhard,
same problem here. it even feels like someone [david :-) ] changed the default setting within the last months. i think it's obvious that i'd like to be notified if someone responds to a post i did. but somehow it happens more and more that i find replies to topics that i wasn't notified of. did we really always have to check that box for notifications?

[turning on notification now]

kuk
Pages: 1 [2] 3 4 ... 20