Go to advanced search

by MrYsLab
Sat Jul 13, 2019 6:26 pm
Forum: Python
Topic: Subprocessing? Calling and terminating a python script from another python script
Replies: 6
Views: 106

Re: Subprocessing? Calling and terminating a python script from another python script

Again, I am not really sure what the code is supposed to do, but a possible solution is to replace the raise statements with continue to go to the next iteration of the loop: if (routineStatus == 1) and (deviceTriggerLocation == deviceLocation): if componentsid == 5 and routineAction == 1: proc1 = s...
by MrYsLab
Sat Jul 13, 2019 5:47 pm
Forum: Python
Topic: Subprocessing? Calling and terminating a python script from another python script
Replies: 6
Views: 106

Re: Subprocessing? Calling and terminating a python script from another python script

It is a little difficult to understand what the coding is actually doing, but I modified it so that proc1 is initialized to None at the top of the loop and to throw an exception if proc1 is None when a kill is called. This should at least point out where the issue is and you can correct from there: ...
by MrYsLab
Sat Jul 13, 2019 2:06 pm
Forum: Python
Topic: Some random error
Replies: 4
Views: 130

Re: Some random error

I think your code structure has lots of issues. I converted your code (untested) to a single class and hopefully this will help you get things going. import openpyxl # read, write excel Sheet import time # import time from system from RPLCD import CharLCD # Configure LCD import RPi.GPIO as GPIO # Co...
by MrYsLab
Thu Jul 11, 2019 2:08 pm
Forum: Python
Topic: BME280 and pigpio python3.7 extentse Name error
Replies: 4
Views: 118

Re: BME280 and pigpio python3.7 extentse Name error

Did you install Python 3.7 yourself or are you using the Buster version of Raspbian? If you did your own install, you may want to burn a new sd card with Buster and try that.
by MrYsLab
Thu Jul 11, 2019 2:00 pm
Forum: Python
Topic: pysftp install fails
Replies: 2
Views: 73

Re: pysftp install fails

The error is caused because the compile can't find Python.h.

To install Python .h, type:

Code: Select all

sudo apt-get install python-dev
If you decide to move to Python3, the command would be:

Code: Select all

sudo apt-get install python3-dev
by MrYsLab
Tue Jul 09, 2019 3:46 pm
Forum: Python
Topic: LMX2594 programming using Python and Raspberry PI
Replies: 11
Views: 252

Re: LMX2594 programming using Python and Raspberry PI

You might want to check out the examples on the pigpio python examples page: http://abyz.me.uk/rpi/pigpio/examples.h ... hon%20code
Although not specific to the LMX2594, there are several SPI examples and perhaps they may give you some ideas.
by MrYsLab
Tue Jul 09, 2019 3:41 pm
Forum: Python
Topic: DHT22 script error handling
Replies: 2
Views: 87

Re: DHT22 script error handling

How about adding a try/except block as shown below. For the degree symbol - that is easy: degree_sign= u'\N{DEGREE SIGN}' temp = 34.5 print(str(temp) + degree_sign) ~ Try/except block added to your code: ##!/usr/bin/python # -*- coding: utf-8 -*- import time import Adafruit_DHT DHT_SENSOR = Adafruit...
by MrYsLab
Sun Jul 07, 2019 2:40 pm
Forum: Python
Topic: tkinter and GPIO, how to set up a physical input button
Replies: 7
Views: 291

Re: tkinter and GPIO, how to set up a physical input button

Wow! You are doing a lot of research. I don't have a lot of experience in this realm, but found a posting that may be of some help:
https://www.raspberrypi.org/forums/view ... p?t=205523

You may also want to look at something like this sensor: https://www.adafruit.com/product/2168
by MrYsLab
Fri Jul 05, 2019 1:06 pm
Forum: Python
Topic: label with textvariable doesn't refresh (tkinter)
Replies: 4
Views: 126

Re: label with textvariable doesn't refresh (tkinter)

I modified your code to just run the tkinter elements and it seems to work without issue.
If you print out the value of InputValue in your getValue function after the readline, what do you get?
by MrYsLab
Mon Jul 01, 2019 11:53 am
Forum: Python
Topic: Doing multiple jobs at the same time
Replies: 3
Views: 285

Re: Doing multiple jobs at the same time

To run the loops concurrently, one solution is to use threading. Here is a great article with working examples: https://pymotw.com/3/threading/ . Your GUI would be the main thread and in its initialization method would spawn and start separate threads for the other 2 loops before starting its own ma...
by MrYsLab
Sun Jun 30, 2019 2:49 pm
Forum: Python
Topic: tkinter and GPIO, how to set up a physical input button
Replies: 7
Views: 291

Re: tkinter and GPIO, how to set up a physical input button

I believe the book you are using, uses the RPi.GPIO library. If I am correct then, RPi.GPIO has a very similar construct to pigpio and instead of callback, they use different terminology and call it interrupt . You may read about it here - just scroll down the page to find the section on interrupts:...
by MrYsLab
Sat Jun 29, 2019 10:57 am
Forum: Python
Topic: Run a asyncio socket function a a thread
Replies: 11
Views: 733

Re: Run a asyncio socket function a a thread

The previous poster is partially correct. It is true, there is no native implementation of ZMQ for MicroPython. Banyan provides a MircoPython script that runs on the ESP and it communicates with a Banyan component called the ESP gateway over TCP/IP. The gateway publishes the information on the Banya...
by MrYsLab
Fri Jun 28, 2019 10:50 pm
Forum: Python
Topic: Restart Race-timer script
Replies: 1
Views: 85

Re: Restart Race-timer script

I am not sure why you are comparing the input values to >0.5 since an input value will be either a 0 or a 1. Not that the would not work, it's just that for digital input values one would not expect to see a floating point number. Below is some code (untested) that may meet your needs. I moved the i...
by MrYsLab
Fri Jun 28, 2019 10:16 pm
Forum: Python
Topic: tkinter and GPIO, how to set up a physical input button
Replies: 7
Views: 291

Re: tkinter and GPIO, how to set up a physical input button

Below is a small tkinter program that converts feet to meters. It also includes code to set a pin as a GPIO input (connected to a pushbutton) and another connected to an LED. Anytime the pushbutton is pressed it will light the LED and when it is released, it will turn off the LED. It uses the pigpio...
by MrYsLab
Fri Jun 28, 2019 11:55 am
Forum: Python
Topic: Run a asyncio socket function a a thread
Replies: 11
Views: 733

Re: Run a asyncio socket function a a thread

You may want to look at python-banyan https://mryslab.github.io/python_banyan/# It is being used by Palace Games and there is an article on the RPi blog that mentions it https://www.raspberrypi.org/blog/raspberry-pi-escape-room/ Banyan requires neither threading or asyncio since it provides concurre...
by MrYsLab
Wed Jun 26, 2019 4:43 pm
Forum: Python
Topic: Python IDE
Replies: 2
Views: 346

Re: Python IDE

If you are a student or contribute to or publish open source software, PyCharm Professional is available free of charge. If not, you can use visual studio code https://code.visualstudio.com/ . It supposedly supports remote debugging: https://code.visualstudio.com/docs/remote/ssh . I have not used th...
by MrYsLab
Wed Jun 26, 2019 4:37 pm
Forum: Python
Topic: Doing multiple jobs at the same time
Replies: 3
Views: 285

Re: Doing multiple jobs at the same time

It is not clear from the code you provided, but your main method which contains a while True loop may be blocking the GUI. Tkinter has its own event loop and you probably should incorporate your while True loop into the tkinter loop by using the tkinter "after" method. Here is one article that provi...
by MrYsLab
Fri Jun 21, 2019 5:14 pm
Forum: Python
Topic: how do you add a module in python
Replies: 4
Views: 358

Re: how do you add a module in python

A few things. First, you only need to import a package once, at the top of your file.
When you installed pyautogui did you use pip or pip3?

You probably want to execute:

Code: Select all

sudo pip3 install pyautogui
by MrYsLab
Fri Jun 21, 2019 2:51 pm
Forum: Python
Topic: python code in raspberry pi 2
Replies: 1
Views: 210

Re: python code in raspberry pi 2

Did you enable i2c using raspi-config?
To see if your i2c device is recognized, you can use i2c-tools. If you do not have that installed, you can install with

Code: Select all

sudo apt-get install -y i2c-tools
Then run:

Code: Select all

i2cdetect -y 1
You should 53 displayed in the command output.
by MrYsLab
Mon Jun 03, 2019 12:01 am
Forum: Python
Topic: Multiple subprocesses
Replies: 10
Views: 379

Re: Multiple subprocesses

Was the 1 frame per second caused by the delay in the read command? If you just read one sensor continuously, what is the maximum number of samples you can read per second? Do you have sample code that runs at the higher fps rate and does it work for you?
by MrYsLab
Sun Jun 02, 2019 10:47 pm
Forum: Python
Topic: Multiple subprocesses
Replies: 10
Views: 379

Re: Multiple subprocesses

Why do you need 4 instances of your C++ code to be running? Does each instance perform different operations on the 4 i2c addresses? If the operations are identical with the exception of the i2c address involved, could you not sequentially call the C++ within the read method? Not being familiar with ...
by MrYsLab
Sun Jun 02, 2019 5:51 am
Forum: Python
Topic: Multiple subprocesses
Replies: 10
Views: 379

Re: Multiple subprocesses

Are you able to retrieve data successfully if you do not use pygame and simply print the data to the console?

If yes, then the problem is integrating your code with the pygame event loop. I am not very familiar with pygame, so perhaps someone else could provide that guidance.
by MrYsLab
Sat Jun 01, 2019 10:18 pm
Forum: Python
Topic: Multiple subprocesses
Replies: 10
Views: 379

Re: Multiple subprocesses

It is not clear to me what you mean when you say Currently, I can get it to work with only one sensor . From what I can see, you are creating 4 objects, each one running the subprocess and then utilizing the objects in your while True loop: while True: for i in range(len(sensors)): print(str(sensors...
by MrYsLab
Fri May 31, 2019 8:32 pm
Forum: Python
Topic: Seeking assistance getting tKinter to play nice
Replies: 7
Views: 318

Re: Seeking assistance getting tKinter to play nice

Glad that I was able to help. BTW, when you see intermittent crashes generally it means there is some timing issue in the code. It took me years to figure that out ;)
by MrYsLab
Fri May 31, 2019 5:46 pm
Forum: Python
Topic: Seeking assistance getting tKinter to play nice
Replies: 7
Views: 318

Re: Seeking assistance getting tKinter to play nice

Here is a quick (and dirty) illustration. I normally write things totally within a class, but this hodgepodge should illustrate the point. from threading import Lock, Thread from time import sleep from tkinter import Tk, Label, Button # create a lock object the_lock = Lock() # acquire the lock def g...

Go to advanced search