Pages: [1]   Go Down
Author Topic: {solved} Best way to store data?  (Read 441 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to set up a way to ping a whole subnet's worth of IP addresses, using ICMPPing (attached), and then later on display the results on an LCD. I know I'm going to need an array of some kind, but I'm wondering what would work best. A few modifiers:

  • I'm using an Arduino Mega, so I have some room to work.
  • I don't know exactly how many IP addresses will be in the array. I'm willing to hard-code it to a max of 256 if need be.
  • The address lengths can vary from as small as 7 to as large as 15 characters.
  • I'm passing a 4-position byte array for the IP address (one for each octet). If I can still use that, that's great, but if I need to convert it to another type, that's fine as well.

I don't have any code yet, because I'm trying to wrap my brain around the whole array thing. What would be best way to do this?

* Arduino-Ping-master.zip (7.1 KB - downloaded 10 times.)
« Last Edit: June 23, 2013, 01:22:28 pm by FTPMonster » Logged

Heemskerk, Netherlands
Offline Offline
Sr. Member
****
Karma: 10
Posts: 406
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If I get it right,
You only need to convert the IP addresses at the moment that you intend to display them. So, you may store the numbers in 4 byte format (what about IPV6?). So theoretically there is no real limit.
4 bytes with 256 addresses would generate 1K size array max.
once you start to display it on an LCD, you can convert it send it to the display and use the same storage for the next IP address. Once it is transferred to the LCD, the variables used to generate the text version of the IP address can be reused again.
« Last Edit: June 23, 2013, 11:56:58 am by nicoverduin » Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8975
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since the addresses are contiguous you can use a bitmap to store a flag (present/not present) for each address.  That will take up 32 bytes for a 256-entry bitmap.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If I get it right,
You only need to convert the IP addresses at the moment that you intend to display them. So, you may store the numbers in 4 byte format (what about IPV6?). So theoretically there is no real limit.
4 bytes with 256 addresses would generate 1K size array max.
once you start to display it on an LCD, you can convert it send it to the display and use the same storage for the next IP address. Once it is transferred to the LCD, the variables used to generate the text version of the IP address can be reused again.

Answers:
IPv6: I'm just happy that the reason I'm building this are actually using IP. smiley If ICMPPing and the W5100 would support v6, I'll add it. But that's for the future.
For the display & use same storage: I found a function that will scroll through an array, and display array and array [i+1] until you press a button, and then it will increment i and display array and array[i+1] until it's completed. Because of that, I need to keep however many IP addresses it finds.

Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Since the addresses are contiguous you can use a bitmap to store a flag (present/not present) for each address.  That will take up 32 bytes for a 256-entry bitmap.
Well, they might not be. I might be getting something like:
192.168.100.1
192.168.100.10
192.168.100.50
192.168.100.101

and because of that randomness I was thinking of just putting it into its own array.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think I was overthinking it. I went with a two-dimensional array, and used sprintf to put the information into a form that I could use. That seemed to work.
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 80
Posts: 1730
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Presumably they will all be on the same network prefix (192.168.100 in your case it would seem). In which case you only need a 1 by n byte array to store the address for each sensor.
Logged

~Tom~

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 653
Posts: 50922
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Well, they might not be. I might be getting something like:
They are contiguous in the sense that the ones you are pinging are all in the 192.168.100.xxx set. There are only 356 possibilities in that range. Using 32 bytes, and bitSet (0 means not answering; 1 means yes, I'm here), you can store all the data in just 32 bytes.
Logged

Pages: [1]   Go Up
Jump to: