Loading ...
Sorry, an error occurred while loading the content.

1096RE: RSS reader thread...

Expand Messages
  • fixitsan2
    Oct 3 3:42 PM

      If I could just now, I would.


      Here's the code though. (Only about 50 lines !)


      import urllib
      import serial
      import time
      ser = serial.Serial()
      ser.port = "/dev/ttyAMA0"
      ser.baudrate = 9600
      ser.bytesize = serial.EIGHTBITS #number of bits per bytes
      ser.parity = serial.PARITY_NONE #set parity check: no parity
      ser.stopbits = serial.STOPBITS_ONE #number of stop bits
      ser.timeout = 1            #non-block read
      ser.xonxoff = False     #disable software flow control
      ser.rtscts = False     #disable hardware (RTS/CTS) flow control
      ser.dsrdtr = False       #disable hardware (DSR/DTR) flow control
      ser.writeTimeout = 2     #timeout for write

      time.sleep(2) #pause 2 secs
      time.sleep(1) # pause 1 sec
      f= urllib.urlopen(u)
      contents = str(f.read())

      ff = open('rssout.txt','w')

      while True:
          i = contents.find('<item>',i)
          if i == -1:
          i= contents.find('<title>',i+1)
          j= contents.find('</title>',i+1)
          message_title = contents[i+7:j]
          i= contents.find('<description>',i+1)
          j= contents.find('</description>',i+1)
          message_description = contents[i+13:j]
          i= contents.find('<pubDate>',i+1)
          j= contents.find('</pubDate>',i+1)
          message_date = contents[i+9:j]
          ff.write('      BBC  ')
          ff.write(message_date+'  ')
          ff.write(message_title+'  ')
          ff.write(message_description+'      '+chr(10))

      f = open('rssout.txt','r')
      contents = f.readline()
      while contents !='':
          l = len(contents)
          for i in range (1,l-6):
          contents = f.readline()







      ---In smartsockets@yahoogroups.com, <Thinwing@...> wrote:

      I WANT!...GIMME...kpc
      In a message dated 10/3/2013 3:15:32 P.M. Pacific Daylight Time, fixitsan@... writes:

       After a bit of playing, I present the Raspberry Pi/Smartsocket RSS reader




      Making this has highlighted a few problems with the existing Smartsocket code. First, there are no lower case characters so I have to convert nice mixed case messages into all uppercase.


      Another problem is that when there a bit punctuation comes along and you're trying to scroll it, there is a clash between the code trying to ignore the invalid punctuation and trying to display the last character. That is why in the video there are occasional double characters at the end of some words.


      The Raspberry Pi TX pin connects via a 220Ohm resistor to the Smartsocket, as a precaution towards problems caused by the difference in system voltages , Raspberry Pi at 3.3V and PIC/Smartsocket at 5V.


      I'm happy to have got this far and really pleased with Python as a language. So far this is just a proof of concept. Now the real work begins because somehow users need to interact with the unit. For example, if you see a feed scrolling past which you've read already, or which isn't of interest, then you ought to be able to perhaps press a button on a remote control to allow you to jump to the next message. Or maybe yoiu want to see the time ?


      The method of operation is roughly as follows..

      - Read the whole RSS page in XML format into one long string (Python seems to be able to cope with massive string lengths)

      - Step through the string till the <item> tag is found , and then capture the date, time, Title and description...and then write that group of data as a single line in a text file (rssout.txt)

      - Once the file is written, the lines are stepped through, one at a time. Each line is read 6-characters at a time and that 6 character wide window is scrolled along, step by step, and appended to a Smartsocket $B7M header.


      Anyway, getting this far proves the hardware side of things, as well as proving that Python, Raspberry Pi, Raspbian OS and a wifi dongle all work well together. I haven't had a single website connection failure or a single wifi problem, so I'm really pleased with the reliability and robustness of this system.






    • Show all 62 messages in this topic