[Python] Variabile non letta (RISOLTO)

Mr.Dob linux a is0gup.com
Gio 16 Apr 2020 18:33:45 CEST


RISOLTO!!!!

In primis un GRAZIE a Marco De Paoli, mi ha aiutato a ragionare e darmi 
il giusto input

ecco il listato funzionante

  #!/usr/bin/env python

import time
import serial
import os
import subprocess

ser = serial.Serial(

  port='/dev/ttyUSB0',
  baudrate = 9600,
  parity=serial.PARITY_NONE,
  stopbits=serial.STOPBITS_ONE,
  bytesize=serial.EIGHTBITS,
  timeout=1)
counter=0
hmi=b'\xFF\xFF\xFF'
cpufreq=subprocess.check_output("cat 
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", shell=True)
cpu=""
cpu += cpufreq.decode()
cpu='''"'''+cpu+'''"'''
buffer=("t55.txt={}".format(cpu)).encode()
ser.write(buffer)
ser.write(hmi)

Il 16/04/2020 17:50, Mr.Dob ha scritto:
> Ho capito l'inghippo
>
> se scrivo
> buffer=("t55.txt={}".format(cpufreq)).encode()
> ho come risultato
> b't55.txt=CIAO'
>
> Invece devo ottenere come risultato
> b't55.txt="CIAO"'
>
> Il 16/04/2020 17:45, Mr.Dob ha scritto:
>> Provato ma nulla.
>>
>> Il costrutto che realizzo sul buffer, b't55.txt= in pratica sto 
>> dichiarando al Display che l'oggetto t55.txt dovrà avere il valore 
>> ="ciao", in questo modo funziona.
>>
>>
>>
>> Il 16/04/2020 17:30, Marco De Paoli ha scritto:
>>>
>>>
>>> Il giorno gio 16 apr 2020 alle ore 17:23 Mr.Dob <linux a is0gup.com 
>>> <mailto:linux a is0gup.com>> ha scritto:
>>>
>>>     Raspberry con linux installato.
>>>     Ho un display seriale, collegato con un convertitore usb/seriale
>>>     collegato tramite porta usb del raspberry.
>>>     Nel display ho realizzato un firmware tramite il tool Nextion
>>>     editor ad oggetti.
>>>     Ho inserito un oggetto text nominato t55.txt dove, via seriale
>>>     gli passo ser.write(b't55.txt="CIAO"')
>>>     Sul display mi visualizzerà la scritta CIAO.
>>>     Se voglio utilizzare una variabile al posto del CIAO questa non
>>>     viene passata.
>>>     Spero di essere stato esaustivo.
>>>
>>>
>>> ok, hai fatto qualche prova con quello che ti ho scritto?
>>>
>>> M.
>>>
>>> _______________________________________________
>>> Python mailing list
>>> Python a lists.python.it
>>> https://lists.python.it/mailman/listinfo/python
>>
>>
>>
>> _______________________________________________
>> Python mailing list
>> Python a lists.python.it
>> https://lists.python.it/mailman/listinfo/python
>
>
>
> _______________________________________________
> Python mailing list
> Python a lists.python.it
> https://lists.python.it/mailman/listinfo/python


-------------- parte successiva --------------
Un allegato HTML è stato rimosso...
URL: <http://lists.python.it/pipermail/python/attachments/20200416/fd670930/attachment-0001.html>


Maggiori informazioni sulla lista Python