Show Posts
Pages: 1 [2] 3 4 ... 6
16  Using Arduino / Programming Questions / Re: Quickest way to search a uint16_t array for a uint16_t value? on: March 24, 2012, 05:59:59 pm
CodingBadly,

Yes, least amount of cpu time is what I am looking for. Not sure how to sort and perform binary search, maybe I could just do a for loop and compare each value. Or I was thinking that I could use memchr, find 1st byte, then test for 2nd byte.

Thanks,

-ren
17  Using Arduino / Programming Questions / Quickest way to search a uint16_t array for a uint16_t value? on: March 24, 2012, 05:47:24 pm
Hello,

I have an array of uint16_t values. What would be the quickest way to identify if the array contained a particular uint16_t value? I have been reading about memchr, but it only appears to compare 1 byte. My code is basically the following.

uint16_t myarray[10];
//put values in myarray
uint16_t somevalue =62000;

Now, I need to search "myarray" to determine if it contains "somevalue", need a function to return true or false. Any assistance would be appreciated.

Thanks,

-ren
18  Using Arduino / Networking, Protocols, and Devices / EthernetServer.cpp multiple connections issue - Not iterating thru active socket on: March 22, 2012, 12:37:57 pm
Hello,

Can any help explain what is going on with these two ethernetclient.cpp functions? I am having an issue with multiple client connections. I think part of the problem is with available function. I don't think it is iterating thru all of the active incoming socket connections, of which there can be 4 with the w5100 ethernetshield.

Thanks,

-ren

void EthernetServer::accept()
{
  int listening = 0;

  for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
    EthernetClient client(sock);

    if (EthernetClass::_server_port[sock] == _port) {
      if (client.status() == SnSR::LISTEN) {
        listening = 1;
      }
      else if (client.status() == SnSR::CLOSE_WAIT && !client.available()) {
        client.stop();
      }
    }
  }

  if (!listening) {
    begin();
  }
}

EthernetClient EthernetServer::available()
{
  accept();

  for (int sock = 0; sock < MAX_SOCK_NUM; sock++) {
    EthernetClient client(sock);
    if (EthernetClass::_server_port[sock] == _port &&
        (client.status() == SnSR::ESTABLISHED ||
         client.status() == SnSR::CLOSE_WAIT)) {
      if (client.available()) {
        // XXX: don't always pick the lowest numbered socket.
        return client;
      }
    }
  }

  return EthernetClient(MAX_SOCK_NUM);
}
19  Using Arduino / Networking, Protocols, and Devices / Official Arduino ethernetshield and the W5100 buffer on: February 21, 2012, 09:35:55 am
Hello,

I am using the Arduino 1.0 Ethernetlibrary. I am using a EthernetServer and EthernetClient. Is it possible to write to the W5100 buffer using EthernetClient.write w/o transmitting the data until a certain byte count is reached? Or could I do this using sockets?

Thanks,

-ren
20  Using Arduino / Networking, Protocols, and Devices / Re: EthernetServer and EthernetClients - Identifying the clients on: February 14, 2012, 12:39:07 am
Zoomkat,

Yes, that is generally the case. In this case it would be a websocket connection.

-ren
21  Using Arduino / Networking, Protocols, and Devices / EthernetServer and EthernetClients - Identifying the clients on: February 13, 2012, 11:32:06 pm
Hello,

I am using an arduino with the official arduino ethernet shield. If you have an EthernetServer that has multiple EthernetClients how do you distinguish between the clients? Can you compare the existing client to server.available to determine if it is an existing connection?

Right now, I can allow a client(s) to connect, evaluate the request, send data back to client and then stop the client connection. However, I want to be able to send data back to the client at a later time.

Thanks,

-ren
22  Using Arduino / Microcontrollers / Re: Where does the 30720 byte maximum size come from? on: February 12, 2012, 05:34:51 pm
westfw,

Thanks, yes, I see you are right about the bootloader size, DA=2048 bytes.

With regards to the sync failure at ~29kb. I should have been more clear. There is some point between 29kb and 30kb that I will get a sync failure. I am just not sure what that value is. I was not saying that I am getting inconsistent results. I was just trying to illustrate that I understand difference between sram and sync failure.

The Uno issue you mentioned got me curious, I tried uploading the same sketch that gave me a sync error onto another 328p arduino, it worked fine. So, I went back to the 328p that gave me the sync error, checked fuses with avrdude-gui, turns out hfuse was set wrong, I updated to DA and now sketch uploads fine.

Thanks for your help,

-ren
23  Using Arduino / Microcontrollers / Where does the 30720 byte maximum size come from? on: February 12, 2012, 04:08:43 am
Hello,

I am a confused with regards to the 30720 byte maximum shown in the arduino ide when I upload a sketch. Where does that come from exactly? Why doesn't the ide indicate this or at least give some general reference? I think it should.

As you can imagine, I am getting close to this limit. I am using a bootloader with hfuse=DA or 1.5kb on the 328p arduino. I upload a sketch of ~29kb. If no ide error prompt and my sketch doesn't run then it is a sram issue, I understand that. However, sometimes I upload a sketch ~29kb and I get a ide sync error. I don't understand, 32-1.5=30.5kb, what's the problem?

Thanks,

-ren
24  Using Arduino / Programming Questions / Re: Sharing a c++ structure between multiple files? on: February 01, 2012, 11:55:25 pm
pYro_65,

Thanks for the info, but there is no way to create the object instance inside the mylibraryfile.cpp file and still access in the .ino file? I will have includes mylibraryfile.h in the .ino file. What is it a problem?

Thanks,

-ren
25  Using Arduino / Programming Questions / Sharing a c++ structure between multiple files? on: February 01, 2012, 11:25:58 pm
Hello,

I am trying to create a structure that I access from a .cpp library file and a .ino(new file ext for pde, created in arduino ide). The structure will have a few variables that I will need to set/get in the myfile.pde and the mylibraryfile.cpp files. Should I define the structure in another .h file, something like mystructure.h? I would like to initialize the structure in the mylibraryfile.cpp file. Currently, my files look like this. Can anyone provide assistance on how to do this?

myfile.ino
mylibraryfile.h
mylibraryfile.cpp

Thanks,

-ren
26  Using Arduino / Programming Questions / Re: Trying to create c++ library using EthernetServer.h on: January 31, 2012, 09:10:49 pm
Nick,

Thanks! I got it working.

-ren
27  Using Arduino / Programming Questions / Re: Trying to create c++ library using EthernetServer.h on: January 31, 2012, 01:46:50 pm
Nick,

I understand, makes sense. I would need to initialize an instance of this class with its constructor. If ethernetserver class does not have a default w/o variable, then I need to use another one of the constructors. However, the code I was referencing uses this same techique, why does it compile successfully? Ref. https://github.com/sirleech/Webduino/blob/master/WebServer.h, excerpt below.

Paul,

Yes, thanks for the tip.

Thanks,

-ren


#include <EthernetClient.h>
#include <EthernetServer.h>


class WebServer: public Print
{public:
...
private: 
EthernetServer m_server; 
EthernetClient m_client;

}
28  Using Arduino / Programming Questions / Trying to create c++ library using EthernetServer.h on: January 31, 2012, 12:17:41 am
Hello,

This is pretty new to me, so bear with me. I am having trouble creating a EthernetServer class instance inside my c++ library class. When I try to compile(below), IDE is telling me that it has no matching function for 'EthernetServer::EthernetServer()' + all the derivatives. I think it is telling that I have to implement the methods of ethernetserver. I don't want to do that. Just want to use it in my class like-> aserver.begin()..etc. Can anybody offer some assistance or guidance on how to learn about this?

Thanks,

-ren


 #include <EthernetClient.h>
 #include <EthernetServer.h>
class myserver: public print
{
public:
.....
private:
EthernetServer aserver;

};


29  Using Arduino / Programming Questions / Re: Unsigned char variable to base 10 char array? on: December 10, 2011, 11:42:51 pm
Nick,

You got me thinking on that last post, maybe the error was somewhere else. I tried a quick code snippet to prove it out(below), it worked. So I reworked my code and it works. I am suprised that itoa can take in an unsigned char.

Thanks,

-ren

void setup() {
  // put your setup code here, to run once:
Serial.begin(57600);
unsigned char value = 255;
char c[3];
itoa(value,c,10);
Serial.println(value,BIN);
Serial.print(c);
}
30  Using Arduino / Programming Questions / Re: Unsigned char variable to base 10 char array? on: December 10, 2011, 10:04:05 pm
Hello,

Thanks for the reply. I am trying not to use sprintf because of the additional space it takes up. I tried itoa, but I wasn't able to get it to work. It was giving negative values when the number exceeded 127.

Thanks,

-ren
Pages: 1 [2] 3 4 ... 6