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

1098RE: RE: RSS reader thread...

Expand Messages
  • fixitsan2
    Oct 8, 2013
    • 0 Attachment

       A quick update.

       

      I've been playing with system stuff on the Raspberry Pi, with the aim of producing something which can work 'headless' - IE no monitor or keyboard required

       
      I've just about worked out a way so that the user needs to only plug in a USB memory stick with a file int he root directory called 'wifi.txt' , which should contain the wifi ssid and password.
       
      Further files on the stick can be used to upload the desired RSS feed URL's and a control file to dictate how often the feeds should be checked.
       
      The idea of a server being included to allow you to change these configuration settings via your laoptop.pc.mac or possibly mobile phone is attractive and currently I'm testing some small http servers. I've loaded up the Apache server and it works but it's just way ott, there are simpler and options available
       
      I've also managed to save the sd card image which I will use for this project which will mean that it ought to be possible for someone to burn the image to an SD card and plug it in, for true plug and play functionality (once the unit knows the wifi password from the usb stick)
       
      I had thoguht of targetting the model A Pi because it's cheaper, but the model B's have just become available for £24 incl p&p which makes ethernet operation feasible at such a low price.
       
      As well as making B7971/zm1350 and IV-17 smartsocket versions, I've also been in contact with a company called Embedded Adventures who are looking to produce a version of their popular 8 x 80 led matrix display as an output device.
       
      Very busy with the day job and my electric motorcycle project at the moment too, but enjoying playing with the Rasp Pi very much indeed.
       
       
      Chris
       
       
       
       
       
       
       
      ---In smartsockets@yahoogroups.com, <smartsockets@yahoogroups.com> wrote:

       

      I've fixed the puctuation issue by adding some punctuation characters in the valid character table of the B7971 code.
       
      The memory use is almost at it's maximum but there don't seem to be any issues, because it all works well.
       
      I probably won't give such frequent updates in the coming days, there's quite a lot I need to do now but it's all structure and file handling stuff which is mundane but needs to work properly. I thought the hard part would be getting the hardware to work for me but that's been good fun and the code for that has been quick to develop.
       
       
      I also know that some RSS sites use a slightly different page delivery format to the BBC one, so I need to look into the different flavours of RSS XML to make sure I can get them all to work as well as I would like.
       
      Naturally there'll need to also be an IV-17 version, probably for 8 tubes ( but 4 tubes could be user set preference)
       
      I need to get a remote control working, but having taken up the only UART tx/rx connections available on the Pi I'll need to go either SPI or I2C for that. At a glance I might need to use a microcontroller after all, to make an I2C>UART bridge to allow me to use one of the cheap bluetooth modules, such as the HC-06 variety. But then again I can remember seeing some cheap wireless remote controls whcih output 4-bit codes to 4 GPIO pins, so that's a possibility.
       
       
       
       
       
       
      ---In smartsockets@yahoogroups.com, <fixitsan@...> wrote:

      If I could just now, I would.

       

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

       

      CODE
      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
      ser.open()

      ser.write(chr(10))
      time.sleep(2) #pause 2 secs
      ser.write("$B7E000000"+chr(13)+chr(10))
      time.sleep(1) # pause 1 sec
       
      f= urllib.urlopen(u)
      contents = str(f.read())
      f.close()
      i=0

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

      while True:
          i = contents.find('<item>',i)
          if i == -1:
              break
          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))
       
      ff.close()

      f = open('rssout.txt','r')
      contents = f.readline()
      while contents !='':
          print(contents)
          l = len(contents)
          for i in range (1,l-6):
              ser.write("$B7M"+contents[i:i+6].upper()+chr(13))
              time.sleep(0.2)    
          contents = f.readline()
      f.close()

       

       

       

       

       

       



      ---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

       

      http://www.youtube.com/watch?v=Zv0RYwwjQdQ&feature=youtu.be

       

      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.

       

      Chris

       

       

       

    • Show all 62 messages in this topic