Show Posts
Pages: 1 2 3 [4] 5 6 ... 14
46  Using Arduino / Programming Questions / Re: Replacing String class . on: March 14, 2014, 12:00:01 pm
inbuff is the HTTP_req and instring is the string you're looking for.


oops, left out another function to clear out the buffer.
it's where you see
Code:
webParser.clearBuffer(queryBuffer, 128);

Code:
void clearBuffer( char *inbuff , int inlength ) {
   //clear out param for new param
    memset(&inbuff[0], 0, inlength);

}
You need to clear out the http_req so you'd get a fresh string every time. I haven't run my server 24/7 yet  but I have a feeling I'll run into your problem down the road.
47  Using Arduino / Programming Questions / Re: Replacing String class . on: March 14, 2014, 11:18:40 am
I'm using char array strings for my server

Code:
#define bufferMax 128 // i know it won't be longer than this
char queryBuffer[bufferMax];
int bufferSize;

void loop()
{
  
  // listen for incoming clients
  WiFiClient client = server.available();
 
  if (client) {
     boolean currentLineIsBlank = true;
     bufferSize = 0;
    
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                if (bufferSize < bufferMax) queryBuffer[bufferSize++] = c;
                 if (c == '\n' && currentLineIsBlank) {
                   parseReceivedRequest(client);
                   bufferSize = 0;
                   webParser.clearBuffer(queryBuffer, 128);
                   break;
                    
                 }
                 if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                }
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
                
            }//end if available
        }//end while connected
    
    
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    Serial.println("client disonnected");
   //
    
  }//end client
  
}


I use this c function to check for strings instead of indexOf

Code:
bool contains(char *inBuff, char *inString) {
   
    if(strstr(inBuff, inString) == NULL) {
        return false;
    } else {
        return true;
    }
}
48  Using Arduino / Programming Questions / Re: I Need To Use a Java Program To Receive Bytes From an MPU Using Bluetooth on: March 13, 2014, 08:25:40 pm
Thanks but I can't spend any more time learning another language.  Especially if it isn't certain that it will solve my problem.
I must have tried 50 different things that might have gotten "close" to helping me but ultimately didn't.  And I lost many many hours trying them

I am in trouble with my boss.  I convinced him I could do it in java not knowing the poor support for the type of devices we work with.

I have to finish NOW!.

If you know java, processing is a breeze. The language is java like. It has java components to read serial if a few lines of code.  Or you can steal processing's serial library and import it into your java app.

It's up to you to  spend a few minute to finish your project or a few weeks.
49  Using Arduino / Programming Questions / Re: How to read multiple sensors through the serial? on: March 13, 2014, 06:07:39 pm
you format the data for the computer to read easily, not necessarily you (human).
It's definitely possible. I can do it in various languages but have no idea how matlab works.
Oh, and 'listen' for a carriage return CR, for an end of serial.println. This will tell whatever app to stop listening and start parsing the serial string.
 
50  Using Arduino / Programming Questions / Re: How to read multiple sensors through the serial? on: March 13, 2014, 03:30:49 pm
Theoretically, You'd need to give each sensor data stream a unique id for matlab or any app that reads it. Like  serial print something like
Sensor1=12.332&sensor2=575.988
Or use a special character for each sensor like
L12.3332b3443.788k333.33
And so on. So then from another app, you'd need to parse this.
51  Using Arduino / Programming Questions / Re: I Need To Use a Java Program To Receive Bytes From an MPU Using Bluetooth on: March 12, 2014, 07:32:44 pm
Processing, built on top of java, can read serial pretty easily.
Go to processing.org
52  Using Arduino / Programming Questions / Re: Debugging Arrays and printing to serial on: March 12, 2014, 03:15:41 pm
What do you want to print?
53  Using Arduino / Programming Questions / Re: Custom class... WHAT? on: March 12, 2014, 03:09:21 pm
Yes, I do it all the time. Look up how to create custom libraries. They're classes mostly.
It'll show you the basic formats.
54  Using Arduino / Programming Questions / Re: Calling child member from Base/Parent array? on: March 12, 2014, 03:06:35 pm
Hacking is encouraged. smiley

No big deal for me. Replace the messed up files with a backup. I have a forum they can go on an ask.
55  Using Arduino / Programming Questions / Re: Calling child member from Base/Parent array? on: March 12, 2014, 12:04:41 pm
I don't for a moment doubt that it works. The writers of various libraries that caused problems for users also believed that their code was perfect.

      "You can't make anything foolproof because fools are so inventive"

Rest assured, if there is any uptake of your project somebody will try to use it in some way that won't work in their situation and the ability to understand the code and make a small modification would probably solve their problem.

...R

Well yeah, people will try to mod it. It should be pretty straight forward for experienced programmers. They'll probably see mistakes I couldn't . This is built for beginners. I wouldn't expect beginners to mess with the code.
56  Using Arduino / Programming Questions / Re: Calling child member from Base/Parent array? on: March 12, 2014, 10:02:48 am
They won't even need to touch the code. It's all web based by configuring settings.

You mustn't read all that many threads here ...

...R

heh, it's working for generic devices that use digital, pwm, and analog in pins. For serial, i2c, or any means, the'd have to write their own class. I'll make sure to make instructions. It works, for reals.

Here's a vid of the progress

57  Using Arduino / Programming Questions / Re: Calling child member from Base/Parent array? on: March 11, 2014, 12:45:53 pm
They won't even need to touch the code. It's all web based by configuring settings.
58  Using Arduino / Installation & Troubleshooting / Re: arduino avrdude: stk500v2_ReceiveMessage(): timeout and Serial PRINT? on: March 11, 2014, 08:58:44 am
Maybe but I didn't have any !!!. I did have ***
I'm using serial prints now with no symbols. Everything is fine now.
59  Using Arduino / Programming Questions / Re: Calling child member from Base/Parent array? on: March 11, 2014, 08:20:25 am
yeah, it is complicated.
I want to make it simple for people to use so obviously, the code has to be complicated.

As long as it doesn't crash, I'm cool with it.
60  Using Arduino / Programming Questions / Re: Calling child member from Base/Parent array? on: March 10, 2014, 09:28:10 pm
I found the answer. I cast it wrong.

this is the right way
Code:
((Relay *)devices[i])->toggleSwitch();
Pages: 1 2 3 [4] 5 6 ... 14