Wifi attachment commands

Related to the development libraries, released by Curt Binder
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

How hard is it to add weboption3?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

Oh i had originally meant to write another slash command for write..whats your thoughts...
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

Well, having a weboption3 would keep the consistency for the way the storing of data works. We already parse for weboption3 with the date/time command. The logic would need to be modified to put in some sanity checks for the command to handle 3 options (to ensure all three exist before writing, etc). The drawback is the amount of data you would be sending to the controller. We couldn't send the whole raw hex memory dump up because of how things get parsed. It's parsed 1 char at a time and reading in a long string would not work because the value would have to be stored in memory before it can be written or processed.
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

The incoming read buffer is a

Code: Select all

static char m_pushback[32];
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

Looks like the set date method can take three args...

So, I'll see about doing this:

/mr - returns standard memory values VarsStart-VarsEnd

/mrx,y - returns location x-y

/mrx,y,z -set memory location x-y with value z
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

binder wrote:Well, having a weboption3 would keep the consistency for the way the storing of data works. We already parse for weboption3 with the date/time command. The logic would need to be modified to put in some sanity checks for the command to handle 3 options (to ensure all three exist before writing, etc). The drawback is the amount of data you would be sending to the controller. We couldn't send the whole raw hex memory dump up because of how things get parsed. It's parsed 1 char at a time and reading in a long string would not work because the value would have to be stored in memory before it can be written or processed.
Hmmmm well writing can be shelved for now...I'd be more interested in solving the negative number issue in that case.

But displaying locations x-y is definitely doable for now...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

binder wrote: We couldn't send the whole raw hex memory dump up because of how things get parsed. It's parsed 1 char at a time and reading in a long string would not work because the value would have to be stored in memory before it can be written or processed.
What I'd we didn't store it and just start writing as we read each character.

We could write a loop from x-y and then start reading in char z writing and discarding as we go. If we y-x > strlen(z) then we can just write 0 or F and if it's less than, we just drop the rest on the floor.

Don't know if this is feasible...
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

I think you will overrun your buffer and loose incoming data by trying to do that loop.
In the other hand, the reading of negative number is easy fixed. The writing of negative numbers can be interpreted as a very large byte or integer.
In reality, there is no such thing as negative number for the controller. The controller only understands 0s or 1s... :shock: , so technically for the controller -1 is the same as 65535.
I just confirmed that you can send "GET /mi,65535" and it will return -1.
This is the workaround for storing negative numbers for now.
I'll look into a more permanent solution later.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

That doesn't help if i want to store a value like negative 73... The controller stores it just fine with write_int function. I don't quite follow the 0/1 analogy. Or the statement that the controller doesn't understand negative numbers...they are just another int, whats to understand?

With the writing of a range shelved, what about writing byte or int as a hex value?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Ok, anyway, based on what you said regarding 65535, the way to enter negative numbers is to subtract the number for UINT_MAX which in this case would be 65536. So in your case, writing 65535 gets -1. For me to get -73 back into the variable, I had to write 65463. I can handle that situation in the html I am working on. All I need to do is if it's a negative number, then add 65536 to it :)

Anyway, so now the only thing left is to fix the display for reading and implement reading custom memory ranges.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

Yeah, correct :)
You got the idea.... For now, this should get you going with storing neg values until a permanent fix is found.
I'll try to patch later today.
Roberto.
enigma32
Posts: 74
Joined: Fri Apr 26, 2013 11:48 am
Location: Los Angeles and NYC

Re: Wifi attachment commands

Post by enigma32 »

If you're bored and want to understand more about what Roberto was talking about, try this: http://en.wikipedia.org/wiki/Two%27s_complement
Signed ints are stored using "twos complement notation" inside the arduino. You'll see a little table on the right hand side toward the top of the page, illustrating storage of positive and negative numbers (although in 8-bit format rather than 16 like your situation).
Current setup:
60g 24" custom cube (fish and softies right now)
AI Sol Blue, Ecotech MP-10wES
Coralife skimmer
100% customer controller, transitioning to ReefAngel
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

great reference. i don't have my old books that discuss that stuff anymore so i couldn't refer to them to post a response. :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

I understand two's compliment and how large numbers are stored in binary representations. I guess the issue for me is that we are storing int's and bytes which are made up of multiple bits. We aren't flipping bits one by one we are doing write() and write_int() one byte at a time. I guess the bigger problem is that from the web we are writing one character at a time and assuming its a digit and dropping non-digits. So the negative is being treated as garbage and being dropped on the floor.

In the case of a /mb request or /mi request we should not drop it on the floor but instead set the signed bit accordingly...

I've got a working front-end storing the value appropriately, but it would simplify a lot if we just did it correctly on the back end.
enigma32
Posts: 74
Joined: Fri Apr 26, 2013 11:48 am
Location: Los Angeles and NYC

Re: Wifi attachment commands

Post by enigma32 »

I would argue that, in the long run, end-user apps shouldn't be worrying about bytes and ints at all.
Hopefully in a week or so I'll have something to show for how I envision this working.

I must admit I still haven't figured out where the params in the request are actually parsed from ascii to byte values... (where is "weboption" set?)
Current setup:
60g 24" custom cube (fish and softies right now)
AI Sol Blue, Ecotech MP-10wES
Coralife skimmer
100% customer controller, transitioning to ReefAngel
binder
Posts: 2871
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Wifi attachment commands

Post by binder »

enigma32 wrote:I would argue that, in the long run, end-user apps shouldn't be worrying about bytes and ints at all.
Hopefully in a week or so I'll have something to show for how I envision this working.
This should be good. I look forward to seeing this. :)
I must admit I still haven't figured out where the params in the request are actually parsed from ascii to byte values... (where is "weboption" set?)
weboption is set in the ELSE clause inside the pushbuffer function.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

Ok, I patched the neg number reading and writing.
Grab the dev branch to test it.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Sweet, I'll try it out tomorrow if I can get some time. I've already pulled it and it's ready to go.

What did you end up doing for the write?
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Wifi attachment commands

Post by lnevo »

I have successfully patched /mr to take two variables to read a custom range in memory. If for some reason the start number is higher than the end number, it returns ERR.

Syntax: /mrX,Y

X = start
Y = end

Pull request pending. :)
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

This code should be added to the html output so that the new /wifi page can fit the display on the phone. It scales great if you double click the page, but this would set it to be default.

Code: Select all

<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=0;" />
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

Thanks!!.
Let me see if it works if I add to the JS.
Roberto.
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

It was already there... It didn't have the min, max and user define, but was there. I added the other ones. Check if it scales now.
On my android, it scales on height, not on width.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

No change... :(

I am getting a lot of unable to refresh data and I know everything is working. My other software is loading data ok...
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Actually it may be worse now.... I cant scale it all now on safari. Not sure what it was like before. I was using chrome in previous tests. Also data loading fine in safari so maybe a chrome issue..
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Chrome is not scaling now either :( ...maybe it was cached..
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

I think it is because of user-scalable=0 that you posted.
I reverted back.
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

I'll have to see if i can make a dev copy of your js file and see what i can do...
rimai
Posts: 12881
Joined: Fri Mar 18, 2011 6:47 pm

Re: Wifi attachment commands

Post by rimai »

This is what I got:
Viewport argument value "device-width;" for key "width" is invalid, and has been ignored. Note that ';' is not a separator in viewport values. The list should be comma-separated.
My original code had comma and when you posted yours, I changed to semi-colon.
So, I updated once again back with a comma. Can you see if it does it now?
Roberto.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

Perfect in safari. Still have issues with Chrome. It doesnt get any data and doesn't default to the right width. Safari is perfect.
User avatar
lnevo
Posts: 5430
Joined: Fri Jul 20, 2012 9:42 am

Re: Wifi attachment commands

Post by lnevo »

14-Radion - Blue Channel
15-Radion - Green Channel
These are reversed in practice... When I set the po14,0 it changed the RFG and when I set po15,0 it changed RFB.

A bit off topic but the reason for this discovery... something is changing my RFB and RFI to 100 and I can't figure it out. I have nothing in my code that references the Radion's at all, except that I'm using the Custom mode for the Vortech... I did have 100 in Mem_B_RadionRadionSlopeEndB and Mem_B_RadionRadionSlopeEndI but I corrected that. Then I overrode the channels to 0 and put back to default and it went right back to 100. It's happened a few times and not sure what's triggering it. Any thoughts?
Post Reply