Dangerous Prototypes

Other projects => Past projects => Web platform => Topic started by: ian on June 22, 2011, 11:42:02 am

Title: Thermal Tweeter
Post by: ian on June 22, 2011, 11:42:02 am
Sjaak and I met up and hacked together a thermal printer with the web platform. It uses the @tweet_tree source to query twitter for the latest tweets to @dangerousproto and prints them.

The setup is really simple. A serial port is assigned to the IO header on the web platform. It outputs (only) serial data to the printer at 19200bps. See the intro article for more about assigning hardware peripherals with PPS.

Last night we got stuck. We could print the first batch of tweets, but each new query resulted in a 404 error. We did a bunch of stuff but couldn't get it.

We ran wire shark to capture the Ethernet packets. We compared a PC query to twitter to the web platforms request (aimed at a server running on a PC in the local network so we could see it). They were byte-for-byte identical.

Next we used modify headers add-on for Firefox to make firefox look exactly like the web platform. Firefox works, web platform doesn't.

We assigned the second UART to the USB->serial converter, and dumped the response from twitter for debugging. This made it easier to see the error without stopping the PIC under debug and reading it from the memory 50bytes at a time. The errors weren't really helpful. (Even if you don't have a thermal printer, you can program the firmware into your web platform and watch the twitter queries from the USB->serial port connection at 115200bps.)

Finally, in a stab in the dark, we increased the TCPIP buffer size and it worked right away. It's really confusing why it looked perfect when aimed at a local server, but caused bad request errors from twitter. Whatever, it works!

Anything you tweet @dangerousproto will print out here. I'll get a live cam up ASAP. This will have some sparse documentation for the Adafruit/Instructables make it tweet contest.
Title: Re: Thermal Tweeter
Post by: Sjaak on June 22, 2011, 12:15:35 pm
Tweetalicious! It was fun to meet and whip something up.

I think you should increase the rpp=1 when we get more popular? Or does it just returns one tweet a time without skipping?

I guess the pic does fragementation which most of the times would cause strange behaviour.
Title: Re: Thermal Tweeter
Post by: ian on June 22, 2011, 12:20:51 pm
I upped the buffer to 2500bytes and increased the tweet pull to 12. That should be enough room for max sized tweets and control characters. It would probably be good to go higher because most are less than the max size and we do have buffer overflow protection.
Title: Re: Thermal Tweeter
Post by: tayken on June 22, 2011, 02:19:49 pm
So that's what you guys were cooking up! I was kinda following along on twitter. Good luck on the contest! :)
Title: Re: Thermal Tweeter
Post by: Sjaak on June 22, 2011, 02:52:42 pm
Ooops we get caught!!

/me runs away!
Title: Re: Thermal Tweeter
Post by: jamz on June 22, 2011, 04:18:59 pm
How it works? here's  the dia and the  png.
Title: Re: Thermal Tweeter
Post by: ian on June 22, 2011, 04:20:34 pm
Thanks Jamz!

A low-res live stream is up, working on a readable one now:
http://www.ustream.tv/channel/thermal-tweeter (http://www.ustream.tv/channel/thermal-tweeter)

A short article will be on the blog today too
Title: Re: Thermal Tweeter
Post by: ian on June 22, 2011, 05:47:12 pm
High-res feed it up now.
Title: Re: Thermal Tweeter
Post by: situbusitgooddog on August 04, 2011, 07:03:56 pm
Hi Ian,
I'm new to all of this and I wonder if you could point me in the right direction, I've recreated this with my own Web Platform and Thermal Printer and loaded it up with your Thermal Tweeter Hex.

In the USB stream I can see the board checking for new tweets but when there's something to print the output I get from the printer is gobbledegook (see I'm learning the technical terms already) - possibly as though the Printer is expecting a different baud rate for the print data? Please see attached image.

Minor teething issues aside I have to say I'm loving the web platform thus far and the possibilities it opens up for personal projects. Thanks in advance.
Title: Re: Thermal Tweeter
Post by: ian on August 05, 2011, 12:39:49 pm
A baud rate issue seems likely. Sjaak had messed with his printer before we used it. The code uses 19,200 BPS, but I think sparkfun lists 9600 as the default (?). Do you also have a Bus Pirate? That would be an easy way to make the change.
Title: Re: Thermal Tweeter
Post by: situbusitgooddog on August 05, 2011, 04:40:26 pm
Thanks for the reply, thought that might be the case.

Unfortunately I don't have a Bus Pirate, but I'm going to have to start getting my head around the code sooner or later anyway so could you point out where the baud rate is set in the code at:
http://code.google.com/p/dangerous-prot ... t_treev1.c (http://code.google.com/p/dangerous-prototypes-open-hardware/source/browse/trunk/Web_Platform/firmware/Thermal_Tweet/tweet_treev1.c) 
then in theory I should be able to edit to 9600 and recompile?

Thanks again, much appreciated.
Title: Re: Thermal Tweeter
Post by: ian on August 05, 2011, 04:55:20 pm
It is just one value that needs to be changed. Unfortunately you will also need to get the TCPIP stack installed and working with these files. I'm afraid that might be a pain with the latest version.

The value is here, there are online calcs to help with it:
http://code.google.com/p/dangerous-prot ... main.c#196 (http://code.google.com/p/dangerous-prototypes-open-hardware/source/browse/trunk/Web_Platform/firmware/Thermal_Tweet/main.c#196)

I would LOVE to port this project to one of the FreeRTOS ports for the web platform.
Title: Re: Thermal Tweeter
Post by: situbusitgooddog on August 05, 2011, 10:43:57 pm
Fantastic, just again another note of appreciation and some info for anyone else trying the same thing.

The magic number for my printer was:
U1BRG = 515

Also I heeded your warning about attempting this with the latest TCPIP Stack version and found Microchip have an archive of older versions here:
http://www.microchip.com/stellent/idcpl ... odeId=2896 (http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2896)

The version I plumped for was Microchip Application Libraries v2010-10-19 and that's working fine.

Another image attached, this time not in gibberish
Title: Re: Thermal Tweeter
Post by: ian on August 06, 2011, 02:14:17 pm
Glad you got it, and thanks for the tip on the old TCPIP versions, I didn't know about them.

Congrats on building the second Thermal Tweeter!
Title: Re: Thermal Tweeter
Post by: Sachiru on March 10, 2012, 06:29:16 am
Cool project!

I'm wondering if this can be modified to print Facebook status updates instead of tweets, and if so, how hard would the required modifications be?
Title: Re: Thermal Tweeter
Post by: ian on March 10, 2012, 11:55:21 am
It depends if Facebook serves Json feeds without authentication. If so, it could be done. If not you might as well do a total rewrite.
Title: Re: Thermal Tweeter
Post by: arupbsk on March 10, 2012, 07:01:20 pm
I guess you need to replace the twitter get url and code to that of the the rss of your facebook status. Well I have no practical idea on what I'm talking about but it maybe one possible way.
Title: Re: Thermal Tweeter
Post by: R3tikus on March 10, 2012, 09:20:47 pm
Really cool proyect! Some questions... Where i can buy? And i can print pictures or lines like a form? Thannks!
Title: Re: Thermal Tweeter
Post by: Sjaak on March 10, 2012, 09:59:16 pm
[quote author="R3tikus"]Really cool proyect! Some questions... Where i can buy? And i can print pictures or lines like a form? Thannks![/quote]

The printer is kinda intelligent and can print text and graphics. Check the datasheet here: http://www.sparkfun.com/products/10438 (http://www.sparkfun.com/products/10438)
Title: Re: Thermal Tweeter
Post by: arupbsk on March 11, 2012, 04:55:58 am
[quote author="R3tikus"]Really cool proyect! Some questions... Where i can buy? And i can print pictures or lines like a form? Thannks![/quote]

Take a look at LadyAda'a guide at http://www.ladyada.net/products/thermalprinter/ (http://www.ladyada.net/products/thermalprinter/)

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.01252131624session_write_close ( )...(null):0
20.01282263216ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.01282263992Database_MySQL->query( ).../DatabaseHandler.php:119
40.05832402728Database_MySQL->error( ).../Db-mysql.class.php:273