python 3.x - When using telnet to sent commands to my raspberry pi I am returned with error: AttributeError: 'tuple' object has no attribute 'encode' -


I am using Telnet to connect with my Raspberry P and I am controlling the 4 serosos associated with it. I have an example of using Python 3. below that I am using code:

  import tkinter import import from telnetlib import sys getpass bot = telnetlib.Telnet ("192.168 .1.128 ") Bot.read_until (b" login: ") bot.write ((" pi \ n "). Encodings ('ascii')) bot.read_until (b" password: ") bot.write ( ("Chamonix007 \ n") .encode ('ascii')) bot.write (("cd /home/pi/pibits/ServoBlaster/user\n").encode('ascii ')) bot.write ((" ("Ascii") encode stbmid (): bot.write (("echo"). 1 = "+ str (mid.get)," & gt; /dev/servoblaster"+"\n").encode('ascii ')) bot.write (("echo 2 =" + s Tr (mid.get), "& gt; / dev / servoblaster" +. "\ N") encode, "& gt ('ascii')) bot.write ((+ str (mid.get" 3 = Echo "); /dev/servoblaster"+"\n").encode('ascii ')) bot.write ((" echo 4 = "+ str (mid.get)," & gt; / dev / servoblaster "+" \ N "). Encode ('ascii')) = middle = scale (master, from_ = 0, = 24 9, height = 550, width = 25, tickiritral = 152, slider_length = 30) mid.set (152 ) Middle.grid (line = 0, column = 8) stbmid = button (master, text = "send to beet", command = stbimid) stbmid.grid (line = 30, column = 8) menloof ()  

If I str (get mid) then it works, however Not when I try to get the value of the scale and try to control the servos there for using that number:

  Exceptions in the Talkator Callback Traceback (most recent In the last call): File "/ Library / Framework / Python. Framework / version / 3/4 / lib / python3.4 / tkinter / __ init__.py ", line 1482, __call__ returns the self.func (* RGS) file" / user / kiloncross / desktop / projects / rapbri_i / robot / control LNI / RPIBO T_CONTROLLER 1.py ", Stabimid Boat in Line 31. written ((" echo 1 = "+ (str. (Midgate)," & gt; / dev / servoblaster "+" \ n ") encode Ascii ')) AttributeError:' Tupl 'object is not a property' encode ' 

I have tried to be the scale as an integer and float but these No one does the work.

I have also tried to make the value of variable instead of str (get.mid)

thanks

Edit

Just such people who are reading this, when I get the code of str (get.mid) I do not use the line of the code bot.write (("echo 1 = 100" / dev / servoblaster "+" \ n "). Encode ('ascii') ) However, at that number where str (get.mid) may be different. / P>


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -