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

Re: [Raspberry_Pi_4-Ham_RADIO] Printing to LCD display

Expand Messages
  • Dave Cochran
    Switch it up a little to continue if Headers.log is rotated, else your script will crash... tail -F /var/log/Headers.log .................... ... -- Dave
    Message 1 of 7 , Mar 24, 2013
    • 0 Attachment
      Switch it up a little to continue if Headers.log is rotated, else your script will crash...

      tail -F /var/log/Headers.log ....................




      On Sun, Mar 24, 2013 at 5:03 PM, John D. Hays <john@...> wrote:
       

      tail -f /var/log/Headers.log | sed 's/.*My: \(.*\) Your.*/\1/' >> /dev/ttyXX  


      (All headers MY field, including /xxxx")

      tail -f /var/log/Headers.log | sed 's/.* DPlus.*My: \(.*\) Your.*/\1/' >> /dev/ttyXX  

      (For only DPlus headers)

      tail -f /var/log/Headers.log | sed 's/.*My: \(.*\)\/.*/\1/' >> /dev/ttyXX  

      (If you don't want the /xxxx)

      John D. Hays
      K7VE
      PO Box 1223, Edmonds, WA 98020-1223 
        



      On Sun, Mar 24, 2013 at 2:06 PM, Rick Simpson <goatguy101@...> wrote:
       

      Ah, the joys of  shell scripting. All you need is a one-line script that pipes the file through a grep statement that selects the portion of the line you want to display through another pipe to the serial port on the LCD. Something of the form:
       
       
      cat Headers.log | grep 'selection phrase' | /dev/ttyXX
       
      I am sure someone on this list can fill in the details  :)
       
      Rick
       
       
      ----- Original Message -----
      Sent: Sunday, March 24, 2013 3:14 PM
      Subject: [Raspberry_Pi_4-Ham_RADIO] Printing to LCD display

       

      Hello all. I bought the 16x2 LCD display from Radio Shack. It has a serial interface so all that is needed is 3 pins from the Pi, some changes in a couple files and you can send text to the screen.

      I'm looking to for anyone that knows how to parse a log file and be able to format it to send to the screen either in python or bash. Below is the format of file from Headers.log

      2013-03-24 18:43:25: DPlus header - My: xx6xxx /DVAP Your: CQCQCQ Rpt1: REF012 A Rpt2: REF012 A Flags: 00 00 00

      I'm looking to capture the callsign after "My:" and send it to the display and have it update the screen as the Headers.log file changes.

      I can echo to the screen and have even made a small python script to display messages but I have no idea how to dynamically take info from a log file and send to the LCD screen.

      Thanks and 73

      Ted
      W6SAT

      P.S. Here is the python script. You have to do a:
      #apt-get install python-serial to get it working.

      root@raspberrypi:/temp# cat hello
      #!/usr/bin/env python
      import serial
      import time

      ser = serial.Serial(port='/dev/ttyAMA0', baudrate=9600)
      if ser.isOpen():
      ser.write(chr(12))
      ser.write(chr(17))
      ser.write("hello")
      ser.write(chr(13))
      ser.write(chr(220))
      ser.write("Dstar")
      time.sleep(3)
      ser.write(chr(12))
      ser.write(chr(18))





      --
      Dave Cochran
      --
      Μολον λαβέ

    • mark_w6sat
      John, I was able to get the latest call to display in the same cursor position on the screen with the following bash shell: root@raspberrypi:/temp# cat mycall
      Message 2 of 7 , Mar 24, 2013
      • 0 Attachment
        John, I was able to get the latest call to display in the same cursor position on the screen with the following bash shell:

        root@raspberrypi:/temp# cat mycall
        #!/bin/bash

        printf '\014' > /dev/ttyAMA0 \\clear screen

        for (( ; ;))
        do
        printf '\014' > /dev/ttyAMA0 \\clears the screen
        tail -n1 /var/log/Headers.log|cut -d " " -f7 > /dev/ttyAMA0
        printf '\015' > /dev/ttyAMA0 \\move cursor back to top
        sleep 2 \\wait 2 seconds
        done


        **in the tail -n1 line the script tails the last line of headers.log and I cut out the 7th field delimited by a space then write the result to /dev/ttyAMA0 (the screen)*****
        I still want to work on the formatting and possibly displaying the current connection state at the bottom of the screen.
        Also, since this loop run all the time I'm thinking I could set the current call to a variable and then only have it update the screen when there was a change.

        If you see any improvements that can be made to my script please let me know.

        Thanks for the help John. Always a pleasure.


        --- In Raspberry_Pi_4-Ham_RADIO@yahoogroups.com, "John D. Hays" <john@...> wrote:
        >
        > *tail -f /var/log/Headers.log | sed 's/.*My: \(.*\) Your.*/\1/' >>
        > /dev/ttyXX *
        >
        > (All headers MY field, including /xxxx")
        >
        > *tail -f /var/log/Headers.log | sed 's/.* DPlus.*My: \(.*\) Your.*/\1/' >>
        > /dev/ttyXX *
        >
        > (For only DPlus headers)
        >
        > *tail -f /var/log/Headers.log | sed 's/.*My: \(.*\)\/.*/\1/' >> /dev/ttyXX *
        >
        >
        > (If you don't want the /xxxx)
        > ------------------------------
        > John D. Hays
        > K7VE
        > PO Box 1223, Edmonds, WA 98020-1223
        > <http://k7ve.org/blog> <http://twitter.com/#!/john_hays>
        > <http://www.facebook.com/john.d.hays>
        >
        >
        >
        > On Sun, Mar 24, 2013 at 2:06 PM, Rick Simpson <goatguy101@...> wrote:
        >
        > > **
        > >
        > >
        > > **
        > > Ah, the joys of shell scripting. All you need is a one-line script that
        > > pipes the file through a grep statement that selects the portion of the
        > > line you want to display through another pipe to the serial port on the
        > > LCD. Something of the form:
        > >
        > >
        > > cat Headers.log | grep 'selection phrase' | /dev/ttyXX
        > >
        > > I am sure someone on this list can fill in the details :)
        > >
        > > Rick
        > >
        > >
        > >
        > > ----- Original Message -----
        > > *From:* mark_w6sat <desertman@...>
        > > *To:* Raspberry_Pi_4-Ham_RADIO@yahoogroups.com
        > > *Sent:* Sunday, March 24, 2013 3:14 PM
        > > *Subject:* [Raspberry_Pi_4-Ham_RADIO] Printing to LCD display
        > >
        > >
        > >
        > > Hello all. I bought the 16x2 LCD display from Radio Shack. It has a serial
        > > interface so all that is needed is 3 pins from the Pi, some changes in a
        > > couple files and you can send text to the screen.
        > >
        > > I'm looking to for anyone that knows how to parse a log file and be able
        > > to format it to send to the screen either in python or bash. Below is the
        > > format of file from Headers.log
        > >
        > > 2013-03-24 18:43:25: DPlus header - My: xx6xxx /DVAP Your: CQCQCQ Rpt1:
        > > REF012 A Rpt2: REF012 A Flags: 00 00 00
        > >
        > > I'm looking to capture the callsign after "My:" and send it to the display
        > > and have it update the screen as the Headers.log file changes.
        > >
        > > I can echo to the screen and have even made a small python script to
        > > display messages but I have no idea how to dynamically take info from a log
        > > file and send to the LCD screen.
        > >
        > > Thanks and 73
        > >
        > > Ted
        > > W6SAT
        > >
        > > P.S. Here is the python script. You have to do a:
        > > #apt-get install python-serial to get it working.
        > >
        > > root@raspberrypi:/temp# cat hello
        > > #!/usr/bin/env python
        > > import serial
        > > import time
        > >
        > > ser = serial.Serial(port='/dev/ttyAMA0', baudrate=9600)
        > > if ser.isOpen():
        > > ser.write(chr(12))
        > > ser.write(chr(17))
        > > ser.write("hello")
        > > ser.write(chr(13))
        > > ser.write(chr(220))
        > > ser.write("Dstar")
        > > time.sleep(3)
        > > ser.write(chr(12))
        > > ser.write(chr(18))
        > >
        > >
        > >
        >
      • mark_w6sat
        John, I was able to get the latest call to display in the same cursor position on the screen with the following bash shell: root@raspberrypi:/temp# cat mycall
        Message 3 of 7 , Mar 24, 2013
        • 0 Attachment
          John, I was able to get the latest call to display in the same cursor position on the screen with the following bash shell:

          root@raspberrypi:/temp# cat mycall
          #!/bin/bash

          printf '\014' > /dev/ttyAMA0 \\clear screen

          for (( ; ;))
          do
          printf '\014' > /dev/ttyAMA0 \\clears the screen
          tail -n1 /var/log/Headers.log|cut -d " " -f7 > /dev/ttyAMA0
          printf '\015' > /dev/ttyAMA0 \\move cursor back to top
          sleep 2 \\wait 2 seconds
          done


          **in the tail -n1 line the script tails the last line of headers.log and I cut out the 7th field delimited by a space then write the result to /dev/ttyAMA0 (the screen)*****
          I still want to work on the formatting and possibly displaying the current connection state at the bottom of the screen.
          Also, since this loop run all the time I'm thinking I could set the current call to a variable and then only have it update the screen when there was a change.

          If you see any improvements that can be made to my script please let me know.

          Thanks for the help John. Always a pleasure.


          --- In Raspberry_Pi_4-Ham_RADIO@yahoogroups.com, "John D. Hays" <john@...> wrote:
          >
          > *tail -f /var/log/Headers.log | sed 's/.*My: \(.*\) Your.*/\1/' >>
          > /dev/ttyXX *
          >
          > (All headers MY field, including /xxxx")
          >
          > *tail -f /var/log/Headers.log | sed 's/.* DPlus.*My: \(.*\) Your.*/\1/' >>
          > /dev/ttyXX *
          >
          > (For only DPlus headers)
          >
          > *tail -f /var/log/Headers.log | sed 's/.*My: \(.*\)\/.*/\1/' >> /dev/ttyXX *
          >
          >
          > (If you don't want the /xxxx)
          > ------------------------------
          > John D. Hays
          > K7VE
          > PO Box 1223, Edmonds, WA 98020-1223
          > <http://k7ve.org/blog> <http://twitter.com/#!/john_hays>
          > <http://www.facebook.com/john.d.hays>
          >
          >
          >
          > On Sun, Mar 24, 2013 at 2:06 PM, Rick Simpson <goatguy101@...> wrote:
          >
          > > **
          > >
          > >
          > > **
          > > Ah, the joys of shell scripting. All you need is a one-line script that
          > > pipes the file through a grep statement that selects the portion of the
          > > line you want to display through another pipe to the serial port on the
          > > LCD. Something of the form:
          > >
          > >
          > > cat Headers.log | grep 'selection phrase' | /dev/ttyXX
          > >
          > > I am sure someone on this list can fill in the details :)
          > >
          > > Rick
          > >
          > >
          > >
          > > ----- Original Message -----
          > > *From:* mark_w6sat <desertman@...>
          > > *To:* Raspberry_Pi_4-Ham_RADIO@yahoogroups.com
          > > *Sent:* Sunday, March 24, 2013 3:14 PM
          > > *Subject:* [Raspberry_Pi_4-Ham_RADIO] Printing to LCD display
          > >
          > >
          > >
          > > Hello all. I bought the 16x2 LCD display from Radio Shack. It has a serial
          > > interface so all that is needed is 3 pins from the Pi, some changes in a
          > > couple files and you can send text to the screen.
          > >
          > > I'm looking to for anyone that knows how to parse a log file and be able
          > > to format it to send to the screen either in python or bash. Below is the
          > > format of file from Headers.log
          > >
          > > 2013-03-24 18:43:25: DPlus header - My: xx6xxx /DVAP Your: CQCQCQ Rpt1:
          > > REF012 A Rpt2: REF012 A Flags: 00 00 00
          > >
          > > I'm looking to capture the callsign after "My:" and send it to the display
          > > and have it update the screen as the Headers.log file changes.
          > >
          > > I can echo to the screen and have even made a small python script to
          > > display messages but I have no idea how to dynamically take info from a log
          > > file and send to the LCD screen.
          > >
          > > Thanks and 73
          > >
          > > Ted
          > > W6SAT
          > >
          > > P.S. Here is the python script. You have to do a:
          > > #apt-get install python-serial to get it working.
          > >
          > > root@raspberrypi:/temp# cat hello
          > > #!/usr/bin/env python
          > > import serial
          > > import time
          > >
          > > ser = serial.Serial(port='/dev/ttyAMA0', baudrate=9600)
          > > if ser.isOpen():
          > > ser.write(chr(12))
          > > ser.write(chr(17))
          > > ser.write("hello")
          > > ser.write(chr(13))
          > > ser.write(chr(220))
          > > ser.write("Dstar")
          > > time.sleep(3)
          > > ser.write(chr(12))
          > > ser.write(chr(18))
          > >
          > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.