Bluetooth data receiving, overload list

1,065 views
Skip to first unread message

M0valis

unread,
Mar 17, 2016, 7:52:46 PM3/17/16
to MIT App Inventor Forum

Hi to everyone :)
I have problem with my app(easy volt meter). I create an app which should allow me to receive data from AVR sending via Bluetooth. It seems to work except the problem with the overloading the list. I'm sending data from avr continously. Putting it to list, and then selecting and spliting. And I'm receiving error: list index too large. Maybye it will be better that I show it on screen. What can I do to make it useful. 
If anyone would have any tips I would be appreciated .

Abraham Getzler

unread,
Mar 18, 2016, 11:02:57 AM3/18/16
to MIT App Inventor Forum
You are mixing lists and quantities.
See attached.
ABG

indeks.png

M0valis

unread,
Mar 18, 2016, 2:58:09 PM3/18/16
to MIT App Inventor Forum
Ok. I deleted that circled part. It works but, now as a test I'm sending data in that configuaration: "?!one?@two?#three?$four?".
But receiving this at proper row, taking a lot of time, and shows me, while transmiting, an error: "invalid text operation
segment: start + length 1 exceeds text length". Is this other way to seperate incoming data and show them in appropriate field? Maybye me technique of segmenting is not that bad ? :)

Taifun

unread,
Mar 18, 2016, 3:14:30 PM3/18/16
to MIT App Inventor Forum
It would really help if you provided a screenshot of your relevant blocks including Do it results, so we can see what you are trying to do, and where the problem may be.

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 

Abraham Getzler

unread,
Mar 18, 2016, 4:54:54 PM3/18/16
to MIT App Inventor Forum
Also, if you are transmitting the data with your own code,
include a copy of the code, so we can see if you are delimitting the end of each message.
ABG

M0valis

unread,
Mar 18, 2016, 5:23:11 PM3/18/16
to mitappinv...@googlegroups.com




This is my whole application:



uart_puts("?!one?@two?#three?$four?");

And this are the uart function:


void uart_putc( char data ) {       
 /* Wait for empty transmit buffer */
        while ( !( UCSRA & (1<<UDRE)) );
        /* Put data into buffer, sends the data */
        UDR = data;
}

void uart_puts( char * s ) {
        while( *s ) uart_putc( *s++ );
}

void uart_putlong( uint32_t liczba, uint8_t radix) {
    char buf[17];
    ltoa( liczba, buf, radix );
    uart_puts(buf);
    }


I have to confess, I'm quite very begginer at programming and this whole issue is beyond me :/ But I really want to finish it :)
Finally I would like to send ADC measurments but for now, I don't know How to make it, and I'm sending some text data.

PS. Here is the fragment of testing adc send:
char wynik[]="    ";
itoa(adc2,wynik,10);
uart_putlong(adc2,10);
When I try to put "wynik" to uart_putlong, I'm getting warning from compiler.

Abraham Getzler

unread,
Mar 18, 2016, 5:36:52 PM3/18/16
to MIT App Inventor Forum
See step 4 here
ABG

Abraham Getzler

unread,
Mar 18, 2016, 5:45:51 PM3/18/16
to MIT App Inventor Forum
You are missing an extra test after the connection test.
You have to test if bluetooth bytes available > 0, else don't try to readtext.

If connected then
   if bytesavailable > 0 then
     read from bluetooth into label.text for debugging
     split from label.text into global list and process it
   else do nothing
else do nothing

Also, what language is doing the sending?
does it have print() and println() to do text conversion for you?

ABG

Abraham Getzler

unread,
Mar 18, 2016, 5:55:45 PM3/18/16
to MIT App Inventor Forum
Also, I see you are expecting four special punctuation characters, (?@#$), each at the beginning of
one of the four ?-delimitted pieces.

But I don't see where in your transmission code you add them to your message.

ABG

Abraham Getzler

unread,
Mar 18, 2016, 6:04:10 PM3/18/16
to MIT App Inventor Forum
And another thing, don't assume you have enough length for your segment() block
when you try to cut off the front of a piece of text.  

Define a result procedure called Tail(s) as returning
  if length(s) > 1 then
     segment(s,2,length(s)-1)
  else 
    empty string

and use Tail(nth piece of your message) one by one in your label assignments.

ABG


M0valis

unread,
Mar 18, 2016, 7:18:54 PM3/18/16
to mitappinv...@googlegroups.com

I made sth like this. It seems to finnaly work. Variable adc1 is an empty list.
Application shows me moving "(!one @two #three $four" on label1 called wynik1. (I don't know why at the beginning is bracket).


Define a result procedure called Tail(s) as returning
 
if length(s) > 1 then
     segment
(s,2,length(s)-1)
 
else
    empty
string


and use Tail(nth piece of your message) one by one in your label assignments.

I don't know where Can I find these expressions.
AVR(Atmega8) has been programmed in C.
These four special characters have me to easier segmentation each part of string.

Today I made this:










But still I don't know How to separate data by characters. Maybye I'm wrong but I think I have to do this beacuse of put incoming data in proper places.

Abraham Getzler

unread,
Mar 19, 2016, 8:49:02 PM3/19/16
to MIT App Inventor Forum
See Chapter 21 of the Wolber book for how to make a function ...

The entire book can be reached through my FAQ:

Assigning the list into a label was just to make sure the data arrived.
But assigning a list into a label ruins it as a list, like running it under a steam roller.
Work from the global variable for all your list operations.

ABG

M0valis

unread,
Mar 20, 2016, 7:23:27 PM3/20/16
to MIT App Inventor Forum
For now, unfortunately I have no idea How to do this :(
I know the procedure is like a function. But I don't know how to use it and generally how to split this incoming strings. How that lists work, and how to use it for my purpose...I'm loosing my hope for do this :/
For now I'm sending proper ADC measurments and I can see them in line moving.

Taifun

unread,
Mar 20, 2016, 7:28:37 PM3/20/16
to MIT App Inventor Forum
A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook   http://www.appinventor.org/book2 ... the links are at the bottom of the Web page.  The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here http://www.appinventor.org/content/CourseInABox/Intro  and the aia files for the projects in the book are here:  http://www.appinventor.org/bookFiles  
How to do a lot of basic things with App Inventor are described here:  http://www.appinventor.org/content/howDoYou/eventHandling  .

Also do the tutorials http://appinventor.mit.edu/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the
 Top 5 Tips: How to learn  App Inventor

You will not find a tutorial, which does exactly what you are looking for. But doing the tutorials (not only reading a little bit) help you to understand, how things are working. This is important and this is the first step to do.

Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by  Taifun.         


M0valis

unread,
Mar 21, 2016, 9:59:29 AM3/21/16
to MIT App Inventor Forum
Thank you for materials. Yes, Probably I won't find exact solution of my problem. But I don't even have idea, how to do this at logical way.
I'm trying to do it for three weeks at least. And I'm desperate because my time is ending, that I decided to write  here.

I would like to ask for help. It does not have to be a ready-made block solution, Maybe some written guidance?
I have to solve this...

Abraham Getzler

unread,
Mar 21, 2016, 10:19:18 AM3/21/16
to MIT App Inventor Forum
Don't give up hope.
You're close.

See attached for how to cut the first character off a piece of text, regardless of its length.

ABG

2016-03-21 10_16_18-5554__build_.png
blocks.png
Designer.png
Tail.aia

M0valis

unread,
Mar 21, 2016, 5:41:00 PM3/21/16
to mitappinv...@googlegroups.com

I made something like this. I'm connected by AiCompanion as you recommended :)
This is a little weird. I've saved once the string data from "main_incoming" by split into "adc1"(but I don;t know the order will be always the same?), and then manually switch "adc1" to "adc2". As a result I was able to segment and select proper item from list. Conclusion is a variable was overcrowded, but now question is how to "pause" data as above, that was a possibility to choosing data properly. Tail's procedure didn't want to work :(.

Abraham Getzler

unread,
Mar 21, 2016, 6:49:05 PM3/21/16
to MIT App Inventor Forum
You are loading your 2nd thru 4th text components from parts of adc1?
But you are splitting the incoming data into adc2.

Read what you wright.
ABG

M0valis

unread,
Mar 21, 2016, 8:29:41 PM3/21/16
to mitappinv...@googlegroups.com

Yes, What I wrote was weird, but Adc1 had to keep previous data.
Above is my last thing that I create. It works (strangely enough), but quite slow I think, timer is set to 500ms. Is it to heavy if I set timer to lower level?

Abraham Getzler

unread,
Mar 21, 2016, 9:19:12 PM3/21/16
to MIT App Inventor Forum
A faster timer would not be a problem, because you are checking for the existence of incoming data each cycle.

But why are you only using the second item of your "?"-delimited list?

ABG

M0valis

unread,
Mar 22, 2016, 6:42:42 AM3/22/16
to MIT App Inventor Forum
Because it's working only with 2nd item. When I tried to choose other item, there was a problem and app shows me something other than I want.

Abraham Getzler

unread,
Mar 22, 2016, 11:31:34 AM3/22/16
to MIT App Inventor Forum
Keep using Do It to show what's going into and coming out of problematic blocks.

Don't be afraid to PrtSc and post wierdness here.

ABG

M0valis

unread,
Mar 22, 2016, 12:08:33 PM3/22/16
to mitappinv...@googlegroups.com

Now it looks like above :) It seems to work correctly all time, but only if I change the item list, as I mentioned before, I see something else in label, I mean for example, If I want to see Vout on 1st bracket I see Ubat :) Until item list is set on 2,  looks good :) I've changed timer to 200ms..Now I have to bite a sending data from app to avr. And count percent capacitance of battery. Is it possible now to take segmented numbers(which are strings) and make arithmetic operation on it?

EDIT:
Ok. I just transfer string variable into numeric variable, and it is ok. But how to count percent value of battery if max. is 4.2V and min. is 3.3V?

Abraham Getzler

unread,
Mar 22, 2016, 12:53:14 PM3/22/16
to MIT App Inventor Forum
The AI2 blocks image export facility is buggy.
Notice how the comment bubbles are empty?

Very uninformative for some one trying to trace data values from blocks.png.

Here's how to get those comment bubbles visible in this forum ...

Is it possible now to take segmented numbers(which are strings) and make arithmetic operation on it?

AI2 automatically  converts strings to numbers in its math blocks.
As far as AI2 is concerned, if it looks like a number, treat it like a number.

ABG

M0valis

unread,
Mar 22, 2016, 1:03:26 PM3/22/16
to mitappinv...@googlegroups.com

Sorry, Yes I didn't notice that, saved and sended, not checked :/ Of course I know what is prtscreen :) But saving image from ai2 is very usefull because I can save whole sheet :)

Abraham Getzler

unread,
Mar 22, 2016, 1:03:38 PM3/22/16
to MIT App Inventor Forum
I looked more closely at your blocks, and see something you have to UNLEARN.

Sometimes, to learn something, you have to unlearn something you learned earlier.

When you were learning to code for Arduino, you probably were told that strings have fixed lengths,
never changing.  

But in AI2, lengths of strings held in variables can change as the contents change.

That's why there is a length() block, to help you limit what you ask for in other blocks like segment().

I see in the Tail() procedure you are asking for both a high start and length, presuming the string will be long enough
to support that segment() call without any insurance from that IF LENGTH() >  test above it.

Your blocks should be bulletproof, verifying all assumptions before acting on them,
and complaining (Notifiers are good) immediately when assumptions fail.

ABG

Abraham Getzler

unread,
Mar 22, 2016, 1:17:56 PM3/22/16
to MIT App Inventor Forum
Now that I can see into your Do Its, I see that you might have some control over the formatting on the sending side?

If you can encode your transmission like {Uvcc:3.14, Ubat:2.718} (an untyped JSON string), you could use 
the Web1.JSONTextDecode block to extract and trim the numbers and names for use in a lookup in pairs block.

(You would have to bring in a Web component to make this block available.)

See attached for how it would work together.

That would eliminate all that splitting and trimming.

ABG


JSON_XYZ_encoding.jpg

M0valis

unread,
Mar 22, 2016, 4:21:05 PM3/22/16
to mitappinv...@googlegroups.com

This would be that what I'm waiting for :) But for now I have to wait even more, phone is charging at the moment..
I've changed the length part back. 
I'm programming avr Atmega8 in pure C, not the arduino. My buffor is set to char wynik[] =""; so it's limited by capacity of variable, that I think, because I'm very beginner at programming, what You can notice :) 
About percentage of battery, I did it, but result is presented with too much precision :/

Edit:
I could not stand:


This the code responsible for sendig data:
 sprintf(wynik,"?Vout:%1.2f [V], ",adc1*VREF*2.2);
    uart_puts(wynik);

    sprintf(wynik,"?Iout:%1.2f [A], ",adc2*0.0050);
    uart_puts(wynik);

    sprintf(wynik,"?Uvcc:%1.2f [V], ",adc3*VREF*2);
    uart_puts(wynik);

    sprintf(wynik,"?Ubat:%1.2f [V]",adc4*VREF*2);
    uart_puts(wynik);


Abraham Getzler

unread,
Mar 22, 2016, 6:19:05 PM3/22/16
to MIT App Inventor Forum
About percentage of battery, I did it, but result is presented with too much precision :/

There is a round() block i the AI2 math blocks section but it would be poisoned by a [V] or [A] suffix (not a number.)


Regarding the JSON decoding, the message arrived without {} brackets and without colons(:), so the JSON decoding failed.

If you want to send {} brackets and colons, you have to squeeze them into the formatting strings of the sprintf C commands. 
I'm weak on C, but judging by what has worked for you so far, I'm guessing you could squeeze them in where you eliminate the "?" split point markers.  But if you do this, you will need to format and send an entire message {...} and have it arrive all at once for the JSON decoding.  

Usually, I've seen people send a closing marker like LF (line feed = decimal 10) to signal end of line, via println().
I'm not sure how it's done in C.

I hope you saved prior versions somewhere (export as .aia file).
Same for your C code, Drpbox is good for version control on the cheap.

ABG




M0valis

unread,
Mar 23, 2016, 1:05:09 PM3/23/16
to mitappinv...@googlegroups.com
The round block, solve the problem with percentage, because I've changed string to numbers :)

OK, I will try with the end of line, but now I'm sending one result by one, because I have one buffor on avr. And it should be in  butterfly brackets?

EDIT:


sprintf(wynik,"{Vo:%1.2f,",adc1*VREF*2.2);
    uart_puts(wynik);

    sprintf(wynik,"Io:%1.2f,",adc2*0.0050);
    uart_puts(wynik);

    sprintf(wynik,"Vb:%1.2f,",adc3*VREF*2);
    uart_puts(wynik);

    sprintf(wynik,"Vu:%1.2f}\n\r",adc4*VREF*2);
    uart_puts(wynik);


On phone when error shows, I see format properly {Vo:5.45, etc}. Maybe float variable is a problem?
Przechwytywanie.PNG

Abraham Getzler

unread,
Mar 23, 2016, 3:18:28 PM3/23/16
to MIT App Inventor Forum
The Block editor's .png export facility is buggy, and doesn't show comment blocks right, so it doesn't help show DoIts.
Use PrtSc for that.

Your error message shot is too small and blurry to make out what arrived in and out of the JSON decode block,
and to see what the error message shows.

The butterfly brackets are needed for the JSON conversion.

Again, the benefit of JSON arrives when you want to pack several different attributes in one message.

ABG

M0valis

unread,
Mar 23, 2016, 3:54:00 PM3/23/16
to MIT App Inventor Forum
The bottom image was for present all blocks. I've corrected post and add attachment :)
I'm trying to send it in one piece from avr but this is the problem probably :/

sprintf(wynik1,"{Vo:%1.2f,",adc1*VREF*2.2);


    sprintf(wynik2,"Io:%1.2f,",adc2*0.0050);


    sprintf(wynik3,"Vb:%1.2f,",adc3*VREF*2);


    sprintf(wynik4,"Vu:%1.2f}\n",adc4*VREF*2);

    strcat(wynik1,wynik2);
    strcat(wynik1,wynik3);
    strcat(wynik1,wynik4);
    
uart_puts(wynik1);



Abraham Getzler

unread,
Mar 23, 2016, 4:20:28 PM3/23/16
to MIT App Inventor Forum
I still can't see what arrived in AI2.
I alo still can't read the error message.
Maybe upload the screen shot sas an attachment  instead of inline?
ABG

M0valis

unread,
Mar 23, 2016, 4:34:20 PM3/23/16
to MIT App Inventor Forum
I upload it before as an attachment too :) But here is now so many messages that it can lost.
Przechwytywanie.PNG

Taifun

unread,
Mar 23, 2016, 4:54:52 PM3/23/16
to mitappinv...@googlegroups.com
well, 99 is not a valid list of lists



Taifun

Abraham Getzler

unread,
Mar 23, 2016, 5:23:58 PM3/23/16
to MIT App Inventor Forum
Show us what is in main_incoming.

To pass theJSON decode block it has to be in JSON format:
{X:345,Y:456,Z:2.4,etc}

Otherwise you won't get the pairs
(
(X 345)
(Y 456)
(Z 2.4))

ABG


M0valis

unread,
Mar 23, 2016, 6:24:53 PM3/23/16
to MIT App Inventor Forum
http://appinventor.mit.edu/explore/ai2/support/blocks/lists#lookupinpairs

It take variable in list form from "main_incoming" and seeking in the structure the key sign, that I think. But this json, has a special structure, which not working in my program at the moment.

Abraham Getzler

unread,
Mar 23, 2016, 6:29:21 PM3/23/16
to MIT App Inventor Forum
Follow the error upstream.
ABG

M0valis

unread,
Mar 23, 2016, 6:47:16 PM3/23/16
to MIT App Inventor Forum
The first letters have to be xyz? I try to send all data in one string but maybe I give bad characters in C.

Abraham Getzler

unread,
Mar 23, 2016, 10:17:56 PM3/23/16
to MIT App Inventor Forum
The first letters have to be xyz? 

No, I was giving an example .

any JsonTextDecode(text jsonText)
Decodes the given JSON encoded value to produce a corresponding AppInventor value. A JSON list [x, y, z] decodes to a list (x y z), A JSON object with name A and value B, (denoted as A:B enclosed in curly braces) decodes to a list ((A B)), that is, a list containing the two-element list (A B).

Here is an example of JSON syntax :

Show us  DoIt screen shot of what goes into the JSONDecode block.

ABG

M0valis

unread,
Mar 24, 2016, 9:07:00 AM3/24/16
to MIT App Inventor Forum
ADC1 is a list variable,rest of variables are strings.
Nothing is changing when I switch variable between string and list. Probably I'm sending wrong data from avr :/
Przechwytywanie.PNG

Abraham Getzler

unread,
Mar 24, 2016, 3:04:31 PM3/24/16
to MIT App Inventor Forum
Data flows from right to left in Ai2 blocks,
from nipple to socket.

So the next place to look and DoIt would be the get global adc1 to the right of the other two DoIts,
to see what kind of garbage was in adc1.

Upstream is to the right.
That's how you follow the pollution in the data river to its source.

ABG

M0valis

unread,
Mar 25, 2016, 5:58:37 PM3/25/16
to MIT App Inventor Forum
I have the problem with the correct sending data from uC, joining data into one string is problem.

Abraham Getzler

unread,
Mar 25, 2016, 6:06:30 PM3/25/16
to MIT App Inventor Forum
If you send a "\n" from the uC, does it arrive as a Line Feed?

For example, if you send "A\nB\nC",  receive it in AI2, and display it in a Label,
does it show as:

A
B
C

?

That would let you specify a delimiter of LF on the AI2 receiving component,
and allow AI2 to ask for everything between one \n and the next \n in one shot.

ABG


M0valis

unread,
Mar 27, 2016, 12:37:08 PM3/27/16
to mitappinv...@googlegroups.com
It shows me something like this.
In app on phone I see:
B
C
A
B
C
I'm sending it like this:
uart_puts("A\n");
uart_puts("B\n");
uart_puts("C\n");

When I've changed the Label "wynik2" for showing "global_adc3" I'm receiving nothing.

rrrr.PNG

Abraham Getzler

unread,
Mar 27, 2016, 1:46:35 PM3/27/16
to MIT App Inventor Forum
This is good news.

That means you have all the tools you need to package all your three or more values with their names in a JSON string, with a \n delimiter at the end, and have it all arrive in a single message in AI2 ready to be parse as a JSON message.

Another user posted a similar problem this last week, and I posted how to handle it in an attached block shot here https://groups.google.com/d/msg/mitappinventortest/6-oePtFZa_0/ZudQoKb8DwAJ

Basically, you need to:

Add a "\n" after the closing "}" on the sending side, making sure there aren't any other \n's inside the message.

Set the AI2 BlueTooth Client in the Designer to have a Delimiter value of 10.

Instead of asking for BytesAvailable in the BTClient.ReceiveText, ask for -1 bytes.
According to the tool tip for that block, that will give you exactly one full message.

Review your sending side to make sure you are still sending a JSON text:
{Name1:Value1,Name2:value2,etc.}\n

ABG

M0valis

unread,
Mar 27, 2016, 4:59:09 PM3/27/16
to mitappinv...@googlegroups.com
It seems to work perfectly but only for few seconds :( Then freezing and app crashing. After added _delay_ms_ app is not crashing but whole value are blinking especially value after dot. And value are unstable, but this could be adc problem.
  sprintf(wynik,"{Vout:%1.2f,",adc1*VREF*2.2);
    uart_puts(wynik);

    sprintf(wynik,"Uvcc:%1.2f,",adc3*VREF*2);
    uart_puts(wynik);

    sprintf(wynik,"Ubat:%1.2f,",adc4*VREF*2);
    uart_puts(wynik);

    sprintf(wynik,"Iout:%1.2f}\n",adc2*0.0050);
    uart_puts(wynik);

_delay_ms(300);


blocks.png
rrrrr.PNG

Abraham Getzler

unread,
Mar 27, 2016, 5:53:30 PM3/27/16
to MIT App Inventor Forum
Maybe your messages are piling up somewhere,
and one is stepping on the heels of the other?

Try to receive twice as often as you send.
Slow down your transmission loop or speed up your receiving clock.

There's a limit to expect in precision from sensors.

You might find it informative to make a LogLabel label component,
and to set LogLabel.Text to Join(get global main_Incoming, "\n", get LogLabel.Text)
after you catch each incoming message, to see if there are any transmission surprises.

How often does your AI2 Clock timer fire?

ABG

M0valis

unread,
Mar 27, 2016, 6:19:30 PM3/27/16
to mitappinv...@googlegroups.com
At appinventor is set to 250ms. But I tried with 100ms too. After few seconds app crashes without delay in uC.
On atmega I have set timer to 31250kHz what is quite fast abot 0.000032ms. Prescaler on timer is set to 256. And main clock is 8MHz.

As you see on attachment incoming data seems to be quite good, but application is crashing :(
rrr2.PNG
rrrrr1.PNG

Abraham Getzler

unread,
Mar 27, 2016, 6:34:02 PM3/27/16
to MIT App Inventor Forum
Here's something to measure...

How long does it take AI2 to process the incoming message in your Timer?
Set a global StartMS to Clock1.MillisecondsfromInstant(Clock1.Now()) when you receive a message.
Set a global FinishMS to Clock1.MillisecondsfromInstant(Clock1.Now()) when you finish processing a message,
Then Display FinishMS-StartMS in a label.text to show how long it took to process.

If it takes longer to process a message than you give to AI2, that can be a problem.

You can speed up your processing by eliminating 75% waste in redoing the JSONDecode block 4 times on the same message.
Catch the JSONDecode output in a global Pairs, and feed Pairs into all those lookup-in-pairs blocks instead.

ABG


Abraham Getzler

unread,
Mar 27, 2016, 6:52:18 PM3/27/16
to MIT App Inventor Forum
Regarding the uC crashes, the Atmel docs would be a better place to look than an AI2 support board.

I would start here ...

ABG

M0valis

unread,
Mar 27, 2016, 7:37:39 PM3/27/16
to MIT App Inventor Forum
No, no UC has no crashes only android app ;)
I created that clock equation, but it doesn't work. Nothing was shown. Take a look on blocks.
Could You extend your idea about saving process time? I have to put it all to one variable and then split again?

Thank you very much for still answering me :) I appreciate that.

blocks.png

Abraham Getzler

unread,
Mar 27, 2016, 8:51:56 PM3/27/16
to MIT App Inventor Forum
Here's the new sequence...

Make a global variable incomingPairs, initially empty list.

after global main_incoming = BTReceiveText(-1) ...
set global incomingPairs = Web1.JSONTextDecode(main_incoming)
set global vout = lookup in pairs ("Uout", get global incomingPairs , "Not found")
wynik1.Text = get global vout
set global vbat = lookup in pairs ("Ubat", get global incomingPairs , "Not found")
wynik2.Text = get global vbat
set global Uvcc = lookup in pairs ("Uvcc", get global incomingPairs , "Not found")
wynik3.Text = get global Uvcc
set global lout = lookup in pairs ("lout", get global incomingPairs , "Not found")
wynik4.Text = get global lout
etc. etc

ABG

M0valis

unread,
Mar 28, 2016, 10:13:45 AM3/28/16
to MIT App Inventor Forum
Thank you it's worknig :) But still app crashing after few seconds :/ I'm runnig it from AiCompanion.

Abraham Getzler

unread,
Mar 28, 2016, 8:09:42 PM3/28/16
to MIT App Inventor Forum
What happens if you build an .apk and run it?

ABG

Abraham Getzler

unread,
Mar 28, 2016, 9:41:30 PM3/28/16
to MIT App Inventor Forum

M0valis

unread,
Mar 29, 2016, 7:00:24 AM3/29/16
to MIT App Inventor Forum
Few seconds after run app is frizzing and then crashes.
I attach the logcat. Errors are at the end of log.
logcat.txt

Abraham Getzler

unread,
Mar 29, 2016, 10:51:27 AM3/29/16
to MIT App Inventor Forum

Abraham Getzler

unread,
Mar 29, 2016, 11:07:15 AM3/29/16
to MIT App Inventor Forum
I don't see anything obvious in the Logcat output, but I am not an Android internals expert.
I see in a recent thread by user Martyn_HK that his sample app disables the timer when it receives control,
and re-enables it at the end of its timer process, I imagine to prevent its processing from being interrupted by
the next clock timer cycle.  
You should probably do that too.

I am going to try to pull Martyn_hk into this thread, to see if we can benefit from his expertise.

ABG

Abraham Getzler

unread,
Mar 29, 2016, 11:09:47 AM3/29/16
to MIT App Inventor Forum

M0valis

unread,
Mar 29, 2016, 5:43:57 PM3/29/16
to MIT App Inventor Forum
Thank you for answering.
For now it looks too hard for me, but maybe I'll try to do that :)
Reply all
Reply to author
Forward
0 new messages