Page 1 of 1

WebServer - Not all Strings Update.

Posted: Sun Feb 12, 2017 8:23 pm
by Jay Dee
Hi all, Using the Webserver component with the WIZ810MJ module. It is working really well, however I can only update 4 strings.

I am updating 6 variables, these are converted to Strings and sent out using the 'SetOutValue' macro.
Then running the 'CheckSocketActivity' macro.
The first 4 strings update as expected, 5 and 6 do not. :?
Is there a limit to the number of Strings that can be updated? I see a setting for 'Max Channels' I assumed this was the number of Client PC's that could talk to the web page at any one time, am I wrong?
If so, any workarounds people can think of?
Thanks, J.

My webserver HTML is..

Code: Select all

<title>Level Monitor</title>
<script type="text/javascript">
function reFresh()

<style type="text/css">
.style1 {
	font-size: xx-large;
	font-weight: bold;
	color: #0000FF;
.style2 {font-size: large; font-weight: bold; color: #00008F; }
<p align="center" class="style1">
Level Sensor Monitor<br>
<p align="center" class="style2">
Level Delta(mm): %1 <br>
Volume(L): %2 <br>
Weight(kg): %3 <br>
Temp(C): %4 <br>
Density(g/L): %5 <br>
Heartbeat: %6 </p>
My Webserver Component Settings are;
(24.49 KiB) Downloaded 13743 times
The Little Web page is working great for the first 4 strings...
(18.58 KiB) Downloaded 13743 times

Re: WebServer - Not all Strings Update.

Posted: Mon Feb 13, 2017 11:47 am
by Benj

The substitution numbers should run from 0 which will provide you an extra swap value.

I have generated a slightly modified component for you which should allow for up to 7 substitutions ranging 0-6.
(25.43 KiB) Downloaded 285 times

Re: WebServer - Not all Strings Update.

Posted: Mon Feb 13, 2017 12:45 pm
by Jay Dee
Thanks Ben,
Thats excellent. Good to know about the Index 0 and the extra couple of substitutions really help.
Tried and tested on hardware, all works as expected.

I only thought this morning.. If I really need to output quite a few variables, I just need to build them into a single long string. Obviously keeping to a sensible limit and not consuming lots of PIC memory.
However, for this project, its all sorted.
(11.11 KiB) Downloaded 13729 times
Cheers, J.

Re: WebServer - Not all Strings Update.

Posted: Tue Mar 28, 2017 8:08 pm
by claudemir
Hello, this topic is speaking my problem as well, since I can only use 6 string how can I do to use more? Because I need to do 10 readings. I'm using mega2560

Re: WebServer - Not all Strings Update.

Posted: Wed Mar 29, 2017 3:43 pm
by Benj

Right I have overhauled the component so that you can now choose how many incoming and outgoing variables and how many bytes to allocate for each variable.
Subs.jpg (21.9 KiB) Viewed 13591 times
This should make much better use of the available RAM as you no longer have to assign 20 bytes to each variable. Usually 4 to 6 bytes work well to pass a numeric value. Be sure to include room for the string null byte so if you want to store 3 characters in the string e.g. "123" then the size should be made to 4 or larger.

You can now have up to 12 outgoing (%0 to %11) and 6 incoming substitutions of variable length. If more are needed then it should be easy to add more, just let me know.

Simply copy the file to your "Flowcode 7/Components" directory before starting Flowcode for the changes to be loaded.
(27.16 KiB) Downloaded 202 times
(28.52 KiB) Downloaded 211 times
(24.92 KiB) Downloaded 211 times
Let me know how you get on.

Re: WebServer - Not all Strings Update.

Posted: Wed Mar 29, 2017 6:01 pm
by claudemir
Sorry for not seeing it before i was in the forum floucode v7
I still have no update, my flowcode v6, how can I use this update for v6 as well?

Re: WebServer - Not all Strings Update.

Posted: Wed Mar 29, 2017 6:04 pm
by Benj
Hmm, v7 only at the moment, I'll see if I can do them for v6 for you.

Re: WebServer - Not all Strings Update.

Posted: Wed Mar 29, 2017 6:11 pm
by Benj
Here is a v6 version of the component with the recent updates, Please note I have not tested this in v6 so make a backup of the existing component first.
(27.46 KiB) Downloaded 224 times

Re: WebServer - Not all Strings Update.

Posted: Wed Mar 29, 2017 7:02 pm
by claudemir
It worked perfectly, just a suggestion, because today I have a project with only 10 read, but future I need something that I can get 20 digital input, so I would have something to change as the programmer needs.
Thanks for the help.

Re: WebServer - Not all Strings Update.

Posted: Wed Apr 05, 2017 12:25 pm
by Benj
Some further improvements for the ESP8266 module here.

I found that the favicon page request was being ignored and that the multiplex channel was not being adhered to when replying as a HTTP server so approx 1 out of every 3 page requests was failing.

This now seems to be much better and is working reliably and much faster than before.
(24.98 KiB) Downloaded 230 times

Re: WebServer - Not all Strings Update.

Posted: Wed Apr 26, 2017 6:30 pm
by claudemir
Ola Benj, you helped me a lot in improving the use of available RAM, with the change made with you read 12 numerical 2-digit variables,
But what I really need is a reading of 20 input variables, is it possible to make that shift to version 6?
Thank you in advance for your support. :D :D

Re: WebServer - Not all Strings Update.

Posted: Thu Apr 27, 2017 9:59 am
by Benj

Would it be possible to combine several readings using a single input.

For example you could do this using 5 input variables.


or you could do something like this using a single input variable.


Here you have 5 variables but only occupying a single input variable. You would then have to parse through the variable splitting the data up every time you hit a comma.

Here is some example code to separate out the values. The data variable would have to be a multi dimensional string variable e.g. data[5][3]

Code: Select all

inputVar = "0,1,23,34,45"
length = Length$(inputVar)
idx = 0
varIdx = 0
subIdx = 0
while (idx < length)
	if (inputVar[idx] = ',')  		//Have we hit a comma
		data[varIdx][subIdx] = 0  	//Terminate current var string
		varIdx = varIdx + 1  		//Move to next var
		subIdx = 0  			//Start at the beginning
		data[varIdx][subIdx] = inputVar[idx]		//Assign data byte to string
		subIdx = subIdx + 1
	idx = idx + 1
data[varIdx][subIdx] = 0			//Terminate final var string
You should end up with something like this in the data variable.

data[0] = "0"
data[1] = "1"
data[2] = "23"
data[3] = "34"
data[4] = "45"

Is this an option for you?

Re: WebServer - Not all Strings Update.

Posted: Thu Apr 27, 2017 3:07 pm
by claudemir
Hello Benj, I will adapt according to the recommendations, I hope it works and meets my needs. I need to do this html reading for those 20 digital input satatus on the hardware.

Re: WebServer - Not all Strings Update.

Posted: Thu Apr 27, 2017 4:13 pm
by chipfryer27

Back in v5 I needed to "serve" around 160 variables but in the forums I was told that I could only have four. So always trying to "break things" I created four arrays and served four strings each with 40 csv. Worked fine for me then (project still running and I still use that code when needed) so I think it should work for you too.


Re: WebServer - Not all Strings Update.

Posted: Thu Apr 27, 2017 4:20 pm
by claudemir
Hello chipfryer27,
Could you show me this code so I can better understand what you've done? Thank you

Re: WebServer - Not all Strings Update.

Posted: Thu Apr 27, 2017 6:08 pm
by chipfryer27

Unfortunately I'm out of the country just now so I don't have access to the code, but if you still need it late May I'll post then.

Basically and briefly from memory:
I needed to read 160 ADC values so what I did was in Variables to create 4 x arrays such as S1[39] to S4[39]. I think I may have been limited in size by available RAM or the like.

I then created a loop using an incremental counter (such as count=count+1) to populate S1 -- S4

The loop would read the ADC then store the ADC at S1[count]=ADC and the increment the loop counter
Once I had filled S1, the loop would then decide to fill S2 --S4 in a similar way

I obviously had other stuff going on to switch inputs to the ADC but we can ignore that.

The v5 webserver component was great. You didn't need to know much about html to get some output. You could just use %variable% and off you went. In the v5 webserver external component properties under Page 1, all I had was the first four variables, then a line break and the next four and so on

%S1[0]% S1[1]% %S1[2]% %S1[3]%
%S1[4]% S1[5]% %S1[6]% %S1[7]%

I think I had to use a maximum of four in a line in the webserver component or it threw a wobbly, not sure why nor cared..:)

To test I simulated with a very slow speed and varied a pot whilst watching the arrays fill in accordance with various counts I had running.

I then had a database reach out to the webserver (at preset times), grab the page in a temporary field, then parse putting the variables in respective fields. This was easy to do as the data positions never changed. I now had 160 individual records.

Hope this is of some small help


Sorry, my memory is bad. In v5 I did as posted but in a v6 project I created $trings.
In a loop I accessed an array and concatenated along the lines of


I can't remember exactly and I probably had to include separators such as "," but again, there are good examples in the help/examples pages. Also it's good to remember that is well documented that you shouldn't try and add too many strings together at one time

Don't do W$=X$+Y$+Z$, instead do W$=W$+X$, then W$=W$+Y$ etc

Re: WebServer - Not all Strings Update.

Posted: Thu Apr 27, 2017 7:00 pm
by claudemir
I can get a notion how to do it, I'll put my hand in the dough and see how far I can go, but I can still get home when I can send the code to see if I'm on the way.
Because I've never worked with Strings for arrays, so I have a bit of difficulty.
Thank you until now

Re: WebServer - Not all Strings Update.

Posted: Thu Apr 27, 2017 7:32 pm
by chipfryer27

The great thing about Flowcode is the forums. People always try and help. If you get stuck please post the code you have and I'm pretty sure someone will help.

There are some help / examples available to show you how to work with arrays / strings etc so please check them out. If I could figure it out anyone can..:) but please be aware though that since v5 the webserver component changed so my example won't work as documented.

If I can help further let me know


Re: WebServer - Not all Strings Update.

Posted: Fri May 12, 2017 2:46 pm
by claudemir
Hello chipfryer27
I have tried to read the position of the byte inside the string in order to use the processor ram, where I need to read 20 digital inputs, I can separate the bytes in the string, but when I access the IP the buttons configured in HTML do not recognize the byte , In the SetOutValue parameter, the position of the byte to be read in the HTML is displayed, the "Yes [0]%" button always appears on the page within the button, the first byte position will always appear on the other two buttons. Where am I going wrong? Please, I need more help, I sent the project to analyze if possible. :oops: :oops: :oops:

Re: WebServer - Not all Strings Update.

Posted: Mon May 15, 2017 9:05 pm
by chipfryer27
Hi Claudemir

Sorry for delayed reply. My access to forum is either feast or famine, due to work commitments.

At present I don't have access to any previous project of mine for reference, and won't until my return, but if you still need help in a week or two I will try. I only have F7 installed on my laptop (which is new to me) as I travel.

I haven't had a chance to look at your flowchart yet, possibly at the weekend, but from your post it sounds as though you are perhaps having HTML issues. I have to confess that is not my strong point. Any HTML I write (well splutter) is only ever visible on a private network and is quite basic, limited to serving values and the odd button or so. Incidentally I read today in another post that F7 has a bug of sorts with String Arrays.

Flowcode does give examples of how to use buttons in a server app so that may be of use to you as well. I think they are in v6 examples.

FC v5 was very user friendly in terms of HTML (for my needs) but onward you now need to know a lot more about creating pages. In v5 if I had a variable called "x" and say x=7, I could use %x% to print the value "7" (because x=7). After v5 that just printed "x" not the value (I think that is the case as I can't remember exactly, but I know things changed as I had to go buy a book on HTML. One day I'll read it).

I'm sorry I'm not much help at present but once back I'll dig out some previous projects to see if I can help further.


Re: WebServer - Not all Strings Update.

Posted: Tue May 16, 2017 11:39 am
by LeighM
Hi Claudemir,

There are quite a few things going on in your program, so it's best we start with something simple.

The SetOutValue() macro sets up a string to go out with the page request.
We now use strings, rather than byte values, as these are more flexible so that we can put text, integers or float values into the page.

So first, any integer/float values have to be converted into a string.
We then pass the string, and an index to identify it, to SetOutValue()
example: SetOutValue(0, "hello world") sets index 0 to "hello world"
and: SetOutValue(1, "me too") sets index 1 to "me too"

Then in the html page property if we have ...

Code: Select all

This page says %0 and %1
The %0 and %1 get substituted with the out strings of index 0 and index 1

Hope that helps and get you started.

Re: WebServer - Not all Strings Update.

Posted: Tue May 16, 2017 9:15 pm
by claudemir
Hello Leighm
I created 20 buttons that trigger 20 digital outputs, and also monitored 20 digital inputs, I created the button in html and in that button the status of each digital input (On or OF) appears, Today it is only possible to read 12 (0 to 11) digital inputs, each input occupying a string. So I try to imagine a way where I can read 20 digitail entries, I also have some limitations on the flocode v6.
But thank you all for the alternatives offered,