Show Posts
Pages: 1 ... 26 27 [28] 29 30 ... 35
406  Using Arduino / Programming Questions / Re: strncpy() causes reset on: April 17, 2012, 06:54:44 am
Quote
I want to use strtok (using \n as delimiter) to parse each line, but first I'm using strncpy() to prevent a
a invalid conversion from 'const char*' to 'char*'
The proper cast would prevent the "problem" without the need to copy the string.

How do I do that?
407  Using Arduino / Programming Questions / Re: strncpy() causes reset on: April 17, 2012, 12:26:06 am
Oops, I should have used:
Code:
strncpy(reply2, reply, strlen(reply))

I made this change but it still reboots.  I don't know about running out of memory.  How do I tell?  When I compile it says Binary Sketch:  18,082 bytes (of a 30,720 byte maximum)
408  Using Arduino / Programming Questions / strncpy() causes reset on: April 16, 2012, 10:14:14 pm
I'm trying to take parse the HTTP reply I get from uploading data to pachube.com.  I'm using EhterCard.h and it has a function tcpReply() that returns the HTTP response, which is

HTTP/1.1 200 OK
Date: Fri, 13 Apr 2012 12:17:36 GMT
Content-Type: text/plain; charset=utf-8
Connection: close
X-Pachube-Logging-Key: logging.Lo55opRx5dl5UwAw2NUO
X-PachubeRequestId: 2ea1be6efb47aac0a0f47ec04196b14f721f605c
Cache-Control: max-age=0
Content-Length: 1
Age: 0
Vary: Accept-Encoding


According to strlen() it's 308 bytes long.  I want to use strtok (using \n as delimiter) to parse each line, but first I'm using strncpy() to prevent a
a invalid conversion from 'const char*' to 'char*'

But my sketch seems to be failing at the strncpy() function and reboots before I even get to strtok().  Below is my code, can anyone tell me what I am doing wrong?

Code:
 
  const char* reply = ether.tcpReply(session);    // part of EtherCard.h library
  if (reply != 0)
  {
    char reply2[strlen(reply)+1];
    strncpy(reply2, reply, sizeof(reply));  // I think Arduino is rebooting here
    reply2[strlen(reply)] = '\0';
   
    char delims[] = "\n";
    char *result = NULL;
    result = strtok( reply2, delims );
    while( result != NULL )
    {
        Serial.println(result);
        result = strtok( NULL, delims );
    }
  }
409  Using Arduino / Motors, Mechanics, and Power / Re: How would I unlock my door? on: April 05, 2012, 08:01:21 pm
You might find this interesting, it's an Arduino that listens to you knocking on the door and if you know the right pattern, it opens the door.


410  Using Arduino / Project Guidance / Re: How To Detect Bluetooth ID on: April 05, 2012, 07:53:38 pm

It's fun when I get to repeat myself.

1. The iPhone doesnt stay in discoverable mode unless initiated by the settings screen.
2.  The iPhone doesn't support the serial profile, so your device won't automatically see your the phone when it is in range.

If you can use a Bluetooth device that supports the HID profile, you might have better luck...

I was hoping that since I'm not really trying to communicate or pair with the iphone (just detect and ID), some of these limitation may still let me get my project to work.  But it sounds like I should wait for a Bluetooth 4.0 shield.  Instead of using bluetooth to unlock the door, maybe I'll just use the thumbprint reader that Adafruit just came out with.  I like the bluetooth project a lot.  I think it would be really cool if a door unlocked as I approached.  But I'm not going to switch phones just for this.
411  Using Arduino / Project Guidance / Re: How To Detect Bluetooth ID on: April 05, 2012, 07:04:50 pm
i don't want to discourage you, but i've heard from several persons that the bluetooth from the iphone is blocked in a certain way z-so it can only communicate with other iphones and computers. So it should be possible, but i think it will be easier with a non-apple phone

You may be onto something with this iphone and bluetooth.  I found this article on Make magazine website that says iphone's don't work with Arduino bluetooth modules, but the new Bluetooth 4.0 might.

http://blog.makezine.com/2012/03/19/bluetooth-4-0-from-arduino-to-iphone-no-jailbreaking-no-mfi/#comment-413239

412  Using Arduino / Project Guidance / Re: How To Detect Bluetooth ID on: April 05, 2012, 05:33:31 pm
If I put the Arduino bluetooth in slave mode and paired it to my iphone, would the iphone then automatically pair with the Arduino bluetooth when I was in range?  If so, would I be able to use Arduino code to see what it was paired with my particular phone.

I've paired my iphone with bluetooth headsets and bluetooth speakers that were not made by Apple and never had a problem, so I don't see how the iphone bluetooth protocal could be restricted to other iphone or computers.
413  Using Arduino / Project Guidance / How To Detect Bluetooth ID on: April 05, 2012, 12:40:36 pm
I'm interested in building an Arduino + Bluetooth project where the Arduino would unlock a door when it detected the bluetooth ID from my phone. I'm not looking for an app running on the phone or anything. I'd want the Arduino to be listening for bluetooth devices and looking for the ID of my phone. When it detects my phone (iPhone 4S) it would trigger one of the outputs to turn on a relay to unlock a door. I've built a few Arduino projects, but I've never done anything with Bluetooth. Would this be hard to do? It would also be nice if I could detect the strength of the bluetooth signal so the Arduino would only keep the door unlocked if the signal strength above a certain level. I'd appreciate any suggestions on how to get started.
414  Development / Other Software Development / Re: New IDE for Mac OS X written in Cocoa (WIP!) on: March 26, 2012, 09:28:26 pm
Cocoduino is now available on GitHub: https://github.com/fabiankr/Cocoduino

Fabian

I noticed in the readme file is said 64-bit O/S.  Is 64-bit necessary or can I run on 32-bit?
415  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 25, 2012, 08:14:24 am
editor3000,

I don't think you understand what we are talking about.  You're examples are for if statements that are executed by arduino while the program is running.  The #if is something different, it's a pre-processor directive tells the IDE how to compile, not run, the program.

Check out:  http://www.cplusplus.com/doc/tutorial/preprocessor/
416  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 24, 2012, 07:31:33 pm
Can you show the offending code? Do you have multiple tabs in your project?

I'm not using tabs.

EthernetDNS.h doesn't compile under Arduino 1.0. It doesn't really matter why. You can find the library here if you're interested:
http://code.google.com/p/arisgames/source/browse/trunk/arduino/libraries/EthernetDNS/?r=2002

I did a little experiment.  I wrote the following sketch.  The file ThisFileDoesNotExist.h does not exist.  This code compiles without errors.   This is what I would expect.  The #if statement is false, so it just skips the include directive.
Code:
#define TEST1 100
#if TEST1 < 100
 #include <ThisFileDoesNotExist.h>
#endif
void setup(){}
void loop(){}
#define TEST1 100

But, the sketch below does give me errors.  EthernetDNS.h does exist (but doesn't compile with Arduino 1.0).  It appears that since this file really exists, the IDE is processing it, even though it's supposed to skip it.

Code:
#define TEST1 100
#if TEST1 < 100
 #include <EthernetDNS.h>
#endif
void setup(){}
void loop(){}
417  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 24, 2012, 04:11:08 pm
Basically the value of ARDUINO is given the numeric value of the release #. And the #if statement works like a C if statement. In this case you are including EthernetDNS.h only when the arduino version is < 100

That part I know.  But ARDUINO = 100, so it should not be including EthernetDNS.h, which it may not be when it's all done.  But it's not totally ignoring it when when I compile the sketch because EthernetDNS.h has errors when compiled in Arduino 1.0.  I was hoping that since my #if statement is false, the compile process would totally ignore EthernetDNS.h, but it doesn't.
418  Using Arduino / Programming Questions / Re: Help Understanding #if directive on: March 24, 2012, 02:36:00 pm
I'm using Arduino 1.0 on my Mac desktop, but I still have Arduino 0022 on my laptop.  I'll probably upgrade the laptop to Arduino 1.0 soon.  It's easy for me to comment the line out when using Arduino 1.0, but I really wanted to get a better understanding of how #if works.  It was not doing what I expected.

--Scott
419  Using Arduino / Programming Questions / Help Understanding #if directive on: March 23, 2012, 08:42:32 pm
I am using Arduino 1.0 and the EthernetDNS.h library isn't compatible with 1.0; I get errors when I try to compile.  Now with Arduino 1.0, I don't even need EthernetDNS.h library, so I tried to exclude it from being compiled when using Arduino 1.0, but I still get compile errors.  When I comment out EthernetDNS.h it compiles fine.  I didn't think the IDE would compile the library if I exclude it with an #if statement like below. 

#if ARDUINO < 100
  #include <EthernetDNS.h> 
#endif

--Scott
420  Using Arduino / Installation & Troubleshooting / Re: Upload Timeout Error on Mega 2560 - Not Sure What Changed on: March 22, 2012, 10:36:48 pm
I have the same problem.  I have a new Mega R3.  I tried both Arduino 0022 and 1.0 on my Mac OSX 10.6.8.  Sometime my sketch will upload fine, but most of the time it times out.  Doing some Google searches, I found this seems to be a known problem, but I'm not sure how to fix it.  I've seen some talk about avrdude, but I don't know anything about fixing, compiling and uploading a boot loader.  Since this problem seems to be kind of old and my hardware and software are new, I'm surprised this problem still exists.  What should I do?
Pages: 1 ... 26 27 [28] 29 30 ... 35