twitwidget - any activity?

Talk about YBoxen, widgets, Propeller hacking, etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
StephMo
 
Posts: 16
Joined: Wed Nov 12, 2008 4:36 am

twitwidget - any activity?

Post by StephMo »

I'm looking at the twitter widget and see that it's using a
basic html request and then parsing the html page returned.

I'm reading the twitter APIs and think just maybe that we could
move this to the REST api and choose a lighter volume form
and process that return instead...

Is work being done on the twitwidget? if work is being done I
don't want to get in the way. Otherwise I could persue a
rewrite using the REST api (maybe the XML return form, not
decided yet.)

I'll hold off if work is in progress...
Please let me know.

-Stephen

StephMo
 
Posts: 16
Joined: Wed Nov 12, 2008 4:36 am

Re: twitwidget - any activity?

Post by StephMo »

I've found that the page layout has changed (as you expected)

You were looking for <div id="status_actions_9999999"
If you change this code to look for <tr id="status_9999999"
the code will work again.

This solves the problem except for the error!6 which appears
to be due to failing to reconnect to the server. (or internal memory
corruption?) I'm tracing the LAN packets now to see which.

Meanwhile change two lines of code in twitwidget.spin as follows

from (323):

Code: Select all

         TMP := strstrn(stringptr, string("<div id=",34,"status_actions_"), 256)
          if ((TMP <> -1) and (status == NO_TWEET))
             status := atoi(stringptr + TMP + 24)
to:

Code: Select all

          TMP := strstrn(stringptr, string("<tr id=",34,"status_"), 256)
          if ((TMP <> -1) and (status == NO_TWEET))
             status := atoi(stringptr + TMP + 15)
Now we are parsing twitter messages again.

Also, the section marked as ' special exception, for the very first tweet
(lines 360 to 395) can now be removed as this no longer applies!

Off to study network trace....

-Stephen

StephMo
 
Posts: 16
Joined: Wed Nov 12, 2008 4:36 am

Re: twitwidget - any activity?

Post by StephMo »

OK, here's a version of the twitwidget (only modified sources) which is lightly modified
to use the Twitter REST API for retreiving twitters. Remainder of functionality is the same.

TV_Text.spin was modified to add more readable functions which the new twitxmlwidget.spin
uses.

Have fun.
Attachments
twitxmlwidget-081123-1830.zip
twitxmlwidget.spin and modified TV_Text.spin as well
(8.98 KiB) Downloaded 672 times

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: twitwidget - any activity?

Post by adafruit »

nice, i actually looked at the API but it seemed like one needed to log-in to get twitters whereas straightup HTML you could just go to the URL. will check this out soon...

User avatar
Helitronix
 
Posts: 7
Joined: Wed Apr 15, 2009 10:01 pm

Re: twitwidget - any activity?

Post by Helitronix »

Stephen,

Thanks for posting this update. I just tried the Twitter widget as it was posted on the YBOX2 page and it wasn't working. So I checked here and found your update. It compiled fine and works well. Thanks for taking the time to submit it.

Joel-

JuJuBee
 
Posts: 18
Joined: Tue Apr 21, 2009 5:32 pm

Re: twitwidget - any activity?

Post by JuJuBee »

Stephen -

Any ideas about an RSS feed reader widget?

JuJuBee

User avatar
samirsky
 
Posts: 14
Joined: Sat Jan 17, 2009 1:01 am

Re: twitwidget - any activity?

Post by samirsky »

I have made the suggested changes and tried the new files posted on this thread. Both give inconsistent results. I don't understand it.

Initially I get error 4, then error 6.
Strange thing is, for some twitter accounts like ladyada or samirsky, if I wait long enough it finally seems to work. With other twitter accounts, like NASA or make, it never gets past the errors.

I tested the IP address and username (http://128.121.146.228/NASA) in my internet browser on my PC on the same network. Works no problem. Other widgets (alarm clock, weather, etc) all work. So my Ybox2 and ability to create the binary seem to be in working order.

Could it be a problem with the DNS? I see on the widget it gets not only an IP address, but also a DNS address on the network. I don't understand why the widget needs and IP address AND a host name. Isn't this redundant?

I was trying this at work since my Ybox2 didn't like my 3COM router at home. Could it be my work router/network is interfering with getting twitter.com? It works fine on my PC, so I don't understand the issue. Could the assigned DNS address redirect away from twitter? Can I force the widget to use the IP address and not do a DNS lookup for twitter.com? (Maybe by leaving the host name blank?)

User avatar
duganj
 
Posts: 14
Joined: Wed Feb 18, 2009 9:41 pm

Re: twitwidget - any activity?

Post by duganj »

Has anyone made any progress with the Error! 6 problem?

Any fixes?

User avatar
samirsky
 
Posts: 14
Joined: Sat Jan 17, 2009 1:01 am

Re: twitwidget - any activity?

Post by samirsky »

StephMo wrote:OK, here's a version of the twitwidget (only modified sources) which is lightly modified
to use the Twitter REST API for retreiving twitters. Remainder of functionality is the same.

TV_Text.spin was modified to add more readable functions which the new twitxmlwidget.spin
uses.

Have fun.
So to use this version for the REST API, what should I put in the "Twitter User:" field?
Instead of "/adafruit", should it be "/statuses/user_timeline.xml?screen_name=adafruit" to get the xml?

User avatar
samirsky
 
Posts: 14
Joined: Sat Jan 17, 2009 1:01 am

Re: twitwidget - any activity?

Post by samirsky »

Think I figured out why the twitxmlwidget (and probably the standard twitwidget) was not working for me:
One of the first things the software does is check the ID of the latest status message (twit) to see if it is new since the last time checked. This is a 10 digit number now. For example the current (as of this message) id for the latest nasa twit is 2742614691.

The status/laststatus is stored in a variable of type 'long' which is a 32-bit number. Signed math in Spin means it can hold a value from -2,147,483,648 to +2,147,483,647 (from the Prop manual). As you can see from the example id above, the id has exceeded the maximum value. I think this caused some sort of overflow/overrun error with that variable.

I don't know Spin, and only enough C/C++ to be dangerous. It did a quick fix by skipping the first digit. This quick hack seems to work, but I don't think it is the 'correct' solution. I change the following line (about line 337):
status := atoi(stringptr + TMP + 4)
to
status := atoi(stringptr + TMP + 5)
I changed the 4 to a 5 to skip the first digit.

I still get an "Error! 6" which I think is a 'connect failed' error. But I am still getting all of the twitter updates (it still works with the error 6).

If anyone can correct this code properly, I would like to have the updated code.

Thanks,
Sam

User avatar
dataman
 
Posts: 98
Joined: Wed May 20, 2009 7:03 pm

Re: twitwidget - any activity?

Post by dataman »

Hmmmm,
I think Dataman will pull the Ybox off the dev shelf and look at this over the weekend.
Very nice find.
Any friend of C++ is a fiend of of Mine#! ;-)

User avatar
dataman
 
Posts: 98
Joined: Wed May 20, 2009 7:03 pm

Re: twitwidget - any activity?

Post by dataman »

I'm looking at the code now,
And though I like your skip the first digit hack,
It's got a fundamental flaw.

A serial number approaches the limit,
And let's use 100 as the limit so we can see it.

98
99
100

The value in last check might be 99
And in New check, 100.
If we skip the first digit.
Er, 00 < 99, that's a fail.

MMM would be a fail right back to 99 again.

So unless we reset the box,
We're probably not going to see anything after a roll over event.

Very unlikely I know, but still possible.

I decided to run with your idea,
And wrote a subroutine to string compare numbers,
and maintain laststatus as a string.

Testing now...

Ok, something is odd.

Can't get my ybox2 to second stage the widget.
Or even the base code I worked from.

I can second stage other programs...

Maybe someone else might have some luck.
Well commented.
Have fun.
Attachments
twitxmlwidget.zip
Compiled, but untested mods to xml widget to support string compare of large serial numbers.
(7.21 KiB) Downloaded 608 times

User avatar
duganj
 
Posts: 14
Joined: Wed Feb 18, 2009 9:41 pm

Re: twitwidget - any activity?

Post by duganj »

I loaded and ran both the Dataman patched and unpatched programs, both seem to function the same for me. The Dataman patched version shows a 0 in the top center of the screen, where as the unpatched version showed a 9 digit series of numbers. From that I could tell that 9 digit series of numbers did not correspond to the twitter id of the status update.

Please excuse my ignorance of spin, I've struggled with it.

I, like Sam, am getting the Error 6 message, and similarly, the program continues to run and show updates. The patched version of the program also clears the screen at regular intervals, alternating with showing the Error 6 message.

I hope this information can help in working some of the bugs out of this program.

Thanks,

John

User avatar
phil.drummond
 
Posts: 125
Joined: Sun Feb 08, 2009 4:57 pm

Re: twitwidget - any activity?

Post by phil.drummond »

Frustrated user here...
I'm trying to get re-interested in my Ybox2 and running into all sorts of irritating problems.
After I re-learned that setting a password is a trouble making mistake, and found out how to clear that problem out, I went to play with new Widgets.
Yes, the most interesting Widget is the Twitter one... so here I am fighting this silly problem.
The original binary is no longer usable (common knowledge), some really cool people have worked on updates (thanks go to them all), and I would like to take advantage of their hard work and skills in place of my own (hard work and skills, skills which I don't possess).
I am really not interested in Spin.
It's not installed, and I am just about at the limit of my patience for this and am not prepared to install/learn Spin.

Sorry, I went on a rant.

Where can I find a binary for the Twitter Widget so I can go have some fun with my Ybox2?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: twitwidget - any activity?

Post by adafruit »

you shouldnt have to learn spin to compile any user additions...but you will have to install the compiler. its pretty deadsimple to use once its installed. just click compile and it 'works' - have you tried grabbing the spincompiler?

Locked
Please be positive and constructive with your questions and comments.

Return to “YBox2 (discontinued)”