Encoding issue - question mark output on php script - Raspberry Pi Forums
i've run issue when trying output results of python script web page. getting if run script via command line i'd call normal output, if run same script through website black diamonds question marks displayed in them. there happens differently how files output when run command line vs when run through php? ideas on else should looking at?
stationid.php script calls python script webpage calls stationid.php file <p>to report bug, please file against fpp-vastfmt plugin project here:
<a href="https://github.com/drlucas/fpp-edmrds/issues/new" target="_new">fpp-edmrds github issues</a></p>
</fieldset>
</div>
<br />
</html>[/code]
, last not least python script that's spitting out output (i have thread bit banging started this).
stationid.php script calls python script
code: select all
<?php $fp = fopen('/tmp/stationid.txt', 'w'); $stationid = exec("sudo python /opt/fpp/plugins/edmrds/rds-song.py -l", $retval); fwrite($fp, "$stationid\n"); fclose($fp); $file = file_get_contents('/tmp/stationid.txt', true); echo $file; ?>
code: select all
<html> <head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#stationid").load('/plugin.php?nopage=1&plugin=edmrds&page=stationid.php'); $("#nowplaying").load('/plugin.php?nopage=1&plugin=edmrds&page=nowplaying.php'); }); </script> </head> <?php exec("if cat /proc/asound/cards | sed -n '/\s[0-9]*\s\[/p' | grep -iq vast; echo 1; else echo 0; fi", $output, $return_val); if ( $return_val ) { error_log("failed our command check fm transmitter"); } $fm_audio = ($output[0] == 1); unset($output); ?> <div id="rds" class="settings"> <fieldset> <legend>edm-lcd-rds-ep support instructions</legend> <p>before use rds capabilities of edm fm transmitter must comfortable soldering , connect scl , sda pins rds chip located within edm fm transmitter 2 pins on raspberry pi. 2 pins use pin 31 , 30 scl , sda respectively. <br><br> see http://www.raspberrypi-spy.co.uk/2012/09/raspberry-pi-p5-header/ more info on pin 30 , 31 located.<br> <br> configuration of rds settings edm transmitter can found here: http://www.edmdesign.com/docs/edm-tx-rds.pdf. information on rds chip inside edm transmitter can found here: http://pira.cz/rds/mrds192.pdf . once connection made can read , set rds information on unit. </p> <p>when create mp3 , ogg files, make sure tag them artist , title fields. can upload mp3s , ogg files through file manager in content setup menu. once tags set, plug in automatically update rds text when file played!</p> <p>known issues: <ul> <li>none</li> </ul> planned features: <ul> <li>connection between edm , pi using supplied usb serial cable <li>set edm station name </ul> station id: <span id="stationid" >loading station id...</span> <br> playing: <span id="nowplaying">loading song...</span> [code]
<a href="https://github.com/drlucas/fpp-edmrds/issues/new" target="_new">fpp-edmrds github issues</a></p>
</fieldset>
</div>
<br />
</html>[/code]
, last not least python script that's spitting out output (i have thread bit banging started this).
code: select all
#!/usr/bin/env python import time import argparse import sys import bb_i2c import pigpio if len(sys.argv) == 1: sys.exit ("the total numbers of arguments passed 1.\nrun app -h command help.") parser = argparse.argumentparser(description='rds setting application') parser.add_argument('-c','--change', help='input station name (8 characters max)', required=false) parser.add_argument('-s','--song',help='song name', required=false) parser.add_argument('-l','--liststation', help='print out station id', required=false, action="store_true") parser.add_argument('-n','--nowplaying', help='print out current radiotext', required=false, action="store_true") parser.add_argument('-w','--write',help='write memory', required=false, action="store_true") args = parser.parse_args() pi = pigpio.pi() s = bb_i2c.i2c(pi, 31, 30, 600) if args.change: #we have station name change #so...set name of radio station if len(args.change) >=9: sys.exit ("the station name has 8 characters or less") stationname = args.change stationname = stationname.rjust(8,' ') s.s() s.tx(214) s.tx(02) x in range(0, 8): # print " %d" % ord(stationname[x]) s.tx(ord(stationname[x])) s.e() print "station name changed to: %s" % stationname # turn off dynamic ps because it's bad (although edm has on default - http://www.rds.org.uk/2010/usage-of-ps.htm) #s.s() #s.tx(214) #s.tx(0x76) #s.tx(0) #s.e() if args.song: #we have change song title playing if len(args.song) >=64: sys.exit ("the song has 64 characters or less") radiotext = args.song radiotext = radiotext.rjust(64,' ') s.s() s.tx(214) s.tx(0x20) x in range(0, 64): # print " %d" % ord(radiotext[x]) s.tx(ord(radiotext[x])) s.e() print "radiotext changed to: %s" % radiotext if args.liststation: #print out radio station id s.s() s.tx(214) s.tx(02) #0x77 dynamic ps 0x20 rt s.s() s.tx(215) number1 = s.rx(1) #1 = ack, 0-nack number2 = s.rx(1) number3 = s.rx(1) number4 = s.rx(1) number5 = s.rx(1) number6 = s.rx(1) number7 = s.rx(1) number8 = s.rx(0) print '%s%s%s%s%s%s%s%s' %(chr(number1) , chr(number2) , chr(number3), chr(number4) , chr(number5) , chr(number6), chr(number7) , chr(number8)) s.e() if args.nowplaying: #print out current radio text information radiotext = "" s.s() s.tx(214) s.tx(0x20) s.s() s.tx(215) x in range(0, 63): #print " %s" % chr(s.rx(1)) radiotext = radiotext + chr(s.rx(1)) radiotext = radiotext + chr(s.rx(0)) s.e() print "%s" % radiotext if args.write: #store settings eeprom print ("saving...") s.s() s.tx(214) s.tx(0x71) s.tx(0x45) s.e() print ("settings saved eeprom") # print ("station name: %s" % args.change ) # print ("song: %s" % args.song ) # print ("write on?: %s" % args.write ) ### # configuration of minirds per http://www.edmdesign.com/docs/edm-tx-rds.pdf # address information , valudes found http://pira.cz/rds/mrds192.pdf # step 1: set pty coding # pty coding (set us) # pty flag set when write eeprom never change otherwise! # pty = program type = 0x0a = value of 2 information # step 2: set subcarier phase shift 85.23 degrees, clock source auto(stero), pll lock range 19000+/- 5hz # step 3: set ps name # step 4: set radio text # dyanmic ps used default ### ### # example of how read byte of data #s.s() #s.tx(214) #s.tx(0x22) #s.s() #s.tx(215) #print(s.rx(0)) #print 'got new device: %s' % chr(79) #s.e() ### ### #set name of radio station #s.s() #s.tx(214) #s.tx(02) #s.tx(ord('x')) #s.tx(ord('m')) #s.tx(ord('a')) #s.tx(ord('s')) # s.tx(ord('m')) #s.tx(ord('u')) #s.tx(ord('z')) #s.tx(ord('k')) #s.e() #store eeprom #s.s() #s.tx(214) #s.tx(0x71) #s.tx(0x45) #s.e() s.cancel() pi.stop()
you should have `od` installed already.
try this:
od -a x -t x1z -v < /tmp/stationid.txt
, post output here.
try this:
od -a x -t x1z -v < /tmp/stationid.txt
, post output here.
raspberrypi
Comments
Post a Comment