Attempt to get item number 2 of a list of length 1: (*empty-string*)<br/><i>Note:</i>
I am a beginner and it’s my first post. Coding on Arduino I discovered App Inventor 3 weeks ago. I tried quite a few tutorials and made a couple of basic apps. Thanks to this forum.
However, right now I am mired for 5 whole long days with an app.
First I made an app for getting time from Arduino’s RTC so has to reset RTC’s time and date from Android. Very basic and it’s working seamlessly.
Then I made an app for getting GPS longitude, latitude and altitude from Android and send them to Arduino. Seamlessly working too.
And I decided to combine both apps in one (name: tabsMINIMA), using the brilliant TABS TABS app from Cyd Carp. And no way to have it work, even though it’s just merging to 2.
MY TROUBLE IS that whatever string I sent the app, it is declaring « empty string » ?
« Select list item: Attempt to get item number 2 of a list of length 1: (*empty-string*)<br/><i>Note:</i> You will not see another error reported for 5 seconds. »
My Arduino string is to be cut into strings using ", "(comma) delimiters.
For testing inventor reception I am using either;
hc06.println ("index1,index2,index3,index4,index5,"); or shorter as the app reads most of the time 3 strings ; hc06.println ("index1,index2,index3 ") ;
My first label in the app displays the whole string sent by Arduino, and it seems ever OK. Then, 3 other labels for respectively index 1, index 2 and index 3. Almost never any display for index 1. Display for index 2 and 3 is very erratic.
Regards to Arduino receiving data from Android, most of the time, any string is missing the last third substring or this one is gibberish.
Notice that when the app is disconnected, it’s tough to connect it again.
Why on earth copy cat of 2 distinct apps are useless when merged? I should miss something but for 5 whole days (and part of nights) I tried every possible trick no way. No pieces of information found on the web. I am out of imagination and turning insomniac and mad. If You can have a look and be indulgent, thanks a lot.
--
See attached
--
problems ....
1, The Do It results will be empty because the data is gone from the buffer after it has been received. To deal with this, receive the data into a global variable and apply the Do It to a get global variable block.
2. You are reusing the global inputslist as a text and as a list. Make a new global inputstext for just the text, and split it into inputslist, which you should initialize as an empty list block. Using two variables makes debugging easier, since it lets you trace back to where things went bad without destroying evidence.
3. Use only a single ReceiveText block in the Timer event, then work from the received global value.
4. Set a Delimiter of 10 in the Designer BT component, to force reception only of full lines delimited by line feed (println). To request only a full line from BT, ask for -1 as your byte count in the ReceiveText (but not in the AvailabletoReceive test)
5. After you split the text into a list and before you go selecting items from it, test the list length, to make sure you don't take a long walk on a short pier.
See the Bluetooth/Arduino section of this FAQ, especially the Delimiter post ...
--
Thanks a lot for Your kindness and Your expertise.
I see that I was very far from finding a solution on my own. Especially because of the Arduino's mentality, global variables are bad.
I am going to implement Your recommendations ASAP though I am now back to work and with less free time. Count on me to keeping You in touch.
Once again I express my deep gratitude to You and the forumites.
--
The link you are providing is truly a gold mine of information, I wish I found it earlier That can curb down quite a few questions from beginners. Thanks a lot Kind regards
--
.
Fantastic, thanks to You, the app is getting data from Arduino perfectly clear. What puzzles me is that "call bluetooth1.client receive text" is still moaning, showing an "?", but not blocking.
Now I have to solve what suddenly is garbling the end of text sent by App to Arduino? Attached what is gotten by Arduino: Ideally D6,N7,Y17 for date, H14,M39 or M40,S(2 digits number) for time , 149.14184,27.08744 for latitude and longitude?????
More homework for me but it's fun. Kind regards. JB
--
I must be terse today, until I can get over today's eye surgery.
--
(The bandage pushes my glasses off my nose so I am one eyed and one handed)
You used the wrong length block on the list that came out of the comma split.
You should have used the corresponding length of list block,
from the lists section of the FAQ.
Read the lists post HOW TO WORK WITH LISTS.
Also post your .ino sketch here, so that a fully powered reader can look at it.
Include a full dowloaded image too.ABG
thanks a lot, just absence-mindedness, now corrected. Please don't waste Your time with my beginner's questions as far as You detect that I am not completely on the wrong tracks.
I wish You a fast recovery. My questions are about my past time, my job is medical diagnostics. I can bet, considering statistics of cases, that your vision will be considerably improved.
--
Thank you for your kind words.
I figured out how to McGyver the glasses.
I now have two hands online.
--
Focal length is a bitch. :)
Congs, You conceived a very astute solution. Perhaps the last time You are wearing glasses.I hope that You aren't suffering and that the patch will be removed tomorrow. Fast recovery. Kind regards.
--
댓글 없음:
댓글 쓰기