Arpitthumar
Posts: 32
Joined: Sat Jun 29, 2019 5:39 am

getting horizontal question question mark symbol instead of code in .py file

Wed Jul 10, 2019 10:13 am

I am getting a big horizontal line of a question mark

??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

like this in my .py file.

gordon77
Posts: 4074
Joined: Sun Aug 05, 2012 3:12 pm

Re: getting horizontal question question mark symbol instead of code in .py file

Wed Jul 10, 2019 10:15 am

what .py file ?

Can you show us the .py script ?

User avatar
Paeryn
Posts: 2613
Joined: Wed Nov 23, 2011 1:10 am
Location: Sheffield, England

Re: getting horizontal question question mark symbol instead of code in .py file

Wed Jul 10, 2019 10:52 am

Generally if you see loads of question marks then the editor / viewer is telling you that each one is a non-printable character (especially if each ? is inside a little box, but that depends on the program). This will happen if you try to open, for example, a binary executable rather than a text file. Or it could be that your text file is corrupt.
She who travels light — forgot something.

ghp
Posts: 1393
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: getting horizontal question question mark symbol instead of code in .py file

Wed Jul 10, 2019 5:15 pm

Sometimes I get long rows of characters when I place some stuff on my keyboard........................................................

Arpitthumar
Posts: 32
Joined: Sat Jun 29, 2019 5:39 am

Re: getting horizontal question question mark symbol instead of code in .py file

Thu Jul 11, 2019 5:23 am

gordon77 wrote:
Wed Jul 10, 2019 10:15 am
what .py file ?

Can you show us the .py script ?
I have been facing this problem for last 2 days. Before that there was not any problem.It generally comes when i shutdown my pc and then restart. Today when I modified wpa__supplicant.conf and restart my pc same thing happen in this file also. There is nothing happen to like stuff on the keyboard.

This is my code.

Code: Select all

import threading
import queue
import serial
import time 
import RPi.GPIO as GPIO
count_enable=0
count=0
#i=0
flag=0
transmit_flag=0
rbuff=list(range(100))
temp=0
#zero_detect=1
print("staring program")
ser=serial.Serial('/dev/ttyAMA0',921600,timeout=1)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(12,GPIO.OUT)

events_queue = queue.Queue()

start = time.time()

def thread_read():
    global count_enable, flag,temp, count
    while True:
        #if transmit_flag==0:
        rbuff=ser.read()
        #for i in range(len(rbuff)):
            #ser.write(rbuff[i])
            #if i >= 100:
            #transmit_flag=1
        if count_enable == 1:
            count+=1
            #print(count)
        if rbuff == chr(0x02) and flag==0: # and zero_detect==1: 
            count_enable=1
            #ser.write(rbuff)
            #print (count)
            flag=1
        if rbuff == chr(0x01) and flag==1  and count==1:
            #ser.write(rbuff)
            #print(count)
            flag=2
        if rbuff == chr(0x04) and flag==2 and count==2:
            #ser.write(rbuff)
            #print(count)
            flag=3
        if rbuff == chr(0x03) and flag==3 and count==3:
            #ser.write(rbuff)
            #print(count)
            flag=4

        if flag==4 and count==28:
            ser.write(rbuff)
            #print(count)
            count=0
            flag=0
        if temp == chr(ord(rbuff)+1) or temp == chr(ord(rbuff)-1) or temp == chr(ord(rbuff)+2) or temp == chr(ord(rbuff)-2) or temp == chr(ord(rbuff)):
            GPIO.output(12,GPIO.LOW)
            #ser.write(ord(buff))
        else:
            GPIO.output(12,GPIO.HIGH)
            temp=rbuff
           # ser.write(ord(buff))

        if count == 1 and rbuff != chr(0x01):
            count_enable=0
            count=0
            flag=0


def thread_check():
    global start
    while True:
        if time.time() - start >= 1:
            start = time.time()
#            print (GPIO.input(12))

read_thread = threading.Thread(target=thread_read)
read_thread.start()

check_thread = threading.Thread(target=thread_check)
check_thread.start()

event=threading.Event()
try:
    event.wait()
except KeyboardInterrupt:
    pass



Return to “Python”