Hi im working on trying to get a key to work throughout the loop without it waiting but constantly works i am using a raspbery pi 3 and the Thonny IDE [closed] - python-3.7

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 days ago.
This post was edited and submitted for review 5 days ago.
Improve this question
Basically I want a key able to be pressed during the entirety of the while True loop. I have tried sys, etc, termios, keyboard and tty with they're respective pip command in terminal on my Raspberry Pi and still no luck any help would be much appreciated. the IDE used is the Thonny IDE with python3.7 running
In short I would like to have a key press available 24/7 In a while loop on a Raspberry Pi python 3.7 Thonny IDE and get the Traceback of
termios.error: (25, 'Inappropriate ioctl for device')
this is where i want to add it but my lab says otherwise
while True:
draw.rectangle((0,0,width,height), outline=0, fill=0)
myfile = open("TempSetm.txt",'r')
for line in myfile:
tempm = line
myfile.close()
sleep(3)
#buncha stuff that the prints stuff out to oled display
code used to get issue was this one
import tty, sys, termios
filedescriptors = termios.tcgetattr(sys.stdin)
tty.setcbreak(sys.stdin)
x = 0
while 1:
x=sys.stdin.read(1)[0]
print("You pressed", x)
if x == "r":
print("If condition is met")
termios.tcsetattr(sys.stdin, termios.TCSADRAIN, filedescriptors)

Related

Change directory to usb drive without using variables [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have a problem to cd into my usb drive (F:) using PowerShell and I can't use variables becouse I am starting PowerShell with Start-Process. I tried using
cd (Get-Volume -FileSystemLabel NameOfUsb).DriveLetter:
and it almost works but "F" has a space after it and ":" is in new line so it spits out error.
Is there any way to do it? It don't have to be using that method
You really should include the full Start-Process line you are trying to run. However, this should do what you want.
cd "$((Get-Volume -FileSystemLabel NameOfUsb).DriveLetter):\"

Camera Fingerprint - Matlab implementation. Help me run this code [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am trying to run this code, but have reached a dead end due to my inexperience.
http://dde.binghamton.edu/download/camera_fingerprint/
The code is trying to call the Cpp fucntion mdwt in MATLAB, and that gives error. I changed the function call in MATLAB to coder.ceval but that gives the error "Too many output arguments." I would be grateful to anyone who would point out what I am doing wrong in implementing this code. Thanks in advance!
These files are source code for mex functions, which can be compiled using the mex command. The compile.m from the zip file contains the necessary commands to compile the mex files.

Undefined function or variable 'stdout' [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I am trying to compile a code for MATLAB. Actually is in C and there is an implementation in matlab. Thus I am using MinGW64 Compiler (C) compiler in order to compile the files. I am running the compiler script which actually compiles using the cmd all the c files. My problem is with a line with fflush(stdout); When I tried to run that command I am receiving the following message:
Undefined function or variable 'stdout'.
I am trying to figure out why am I receiving that error, and what is about.
The code is the following:
disp('Compiling for Matlab...');
gcc = 'mex';
cd mex;
% =============
% Learning code
disp('Learning:');
files = {'qp_one_sparse.cc', 'score.cc', 'lincomb.cc'};
matlabflags = '-O -largeArrayDims';
for n = 1:length(files)
cmd = [gcc ' ' matlabflags ' ' files{n}];
disp([' ' cmd]);
fflush(stdout);
eval(cmd);
end
I got issues with fflush(stdout); line
fflush(stdout) is valid in Octave but not MATLAB.
If you need to flush the output, you can drawnow to achieve the same effect in MATLAB.
drawnow('update')
The update parameter ensures that only non-graphical queues are flushed.
In newer versions of MATLAB, the following is preferred but either should work.
drawnow('limitrate')
That being said, I'm not sure that you even need it for the code that you've posted.

Recursion limit? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
When I run my code on my laptop it runs without error,but when I run it from an old computer it throws me the error:
Maximum recursion limit of 500 reached. Use set(0,'RecursionLimit',N) to change the limit. Be aware that exceeding your available stack space can crash MATLAB and/or your computer. Error in coder.allowpcode
I need to run my code from the old computer.I set also the recursion limit to a bigger value but my MATLAB program crash.
A 500 recursion is quite big, are you sure the code is good? Or are you recurring too often?
Assuming you code is good:
Your Matlab program crashes because you are causing a Stackoverflow (yeah that's why this site has that name and that logo!).
The Stack memory in a computer is a memory that saves a link to "where the function has been called". Nowadays, modern computers have a decent Stack memory, but old ones didn't. If you overflow that memory, when the execution of a code is "finishing" and getting out the functions to the parent function, eventually it won't know where to go (because there was no enough space in the Stack memory). This will cause a crash of your system (or Matlab).
There is nothing you can do about this (if your code is correct). Basically do not use big recursion in old computers.

How to send input file name to args:Array[String] from a script in Scala? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a program reading one file and I want to read multiple files so I wrote a script to read those files and send them to the program (args in main) but some how it is not getting the input. I wanted to know the possible ways that I can send info to args(1).
Instead of piping the files to Java (via |) you should simply invoke your Scala program with the JPG argument appended. (I'm assuming Scala since that's what you have tagged your question with.)
Something like:
scala YourScalaProgram tmp.jpg
assuming that all necessary jars, etc., are on your CLASSPATH.