How could I launch code.py that only exists on a raspberry, from a python command line on a computer connected by an Ethernet cable. Machine A and the raspberry are connected to each other by a simple ethernet cable, and none of those two endpoints are connected to the internet. They only have the latest version of python installed and can't have anything more installed on them.
It looks like subprocess.Popen() could be a way to tackle it. But with the little knowledge I have I can't understand and know for sure if using this method is suitable !
Thank you for your time :)
Related
I am attempting to send data from a Python script running on a Raspberry Pi to a Java Micronaut ServerWebSocket running on a Windows machine, but I am getting asyncio.exceptions.TimeoutError errors during the process.
I attempted to use the websockets library in Python on the Raspberry Pi to establish a websocket connection, but encountered a ConnectionRefusedError. Is this issue related to a network problem as mentioned here, and should I ask somewhere else like Superuser or Serverfault? Or is there another solution to this problem?
As #life888888 suggested, it had something to do with Windows firewall.
But instead of the public firewall being the problem, it was the one for the domain network instead.
I have a modem and four Esp8266 and a Raspberry Pi. I want to control Esp with Python language via internet. I have read this project.
https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/
Instead of ESP2, I implemented the code on Windows. But I got the error ModuleNotFoundError: No module named 'ustruct'.
Is there a way for me to remotely check the Raspberry Pi and ESPs using Windows?
Of course I want to use MQTT.
This photo shows what I have described.
ustruct is a MicroPython Module that is available on all if not most MicroPython firmwares ( including the Win32 version of MicroPython)
If you need to / want to port your code to Cpython (on windows or other) that should not be too much work as the two are quite compatible.
as your project needs network capabilities using the Windows port of MicroPython is not an option as neither the Unix nor the Widows ports come with a network stack you compile/download a windows port of MicroPython
In my application I want to turn on certain GPIO pins that are on the Raspberry Pi from my PC's C++ script. My PC is currently running on Windows 10 and my Raspberry Pi on Raspbian.
The general idea I had was to write python scripts on the Raspberry Pi itself and run them somehow from my PC when needed. Although, I am not sure how to do this or if it's possible in C++. I know I can ssh into my Raspberry Pi and run scripts manually but the idea of this application is automation. I am able to connect my PC to the Raspberry Pi either by Ethernet or USB cables.
I have seen USB to GPIO modules that would probably work better although for now I am stuck with my Raspberry Pi.
Any knowledge or resources on how to do this is greatly appreciated.
Maybe be what you need is a client and server program to control your GPIO pins. Check out my client and server programs and dont forget to read the answer and its comments and make the change accordingly for the program to work.(My progams motives is to control an LED through the client and server programs , similar to controlling the GPIO pins )
Program getting stuck at accept statement
PS: I hope you are having some knowledge about Threading and sockets.
This answer will be pretty broad so feel free to leave a comment with questions.
The first things that are needed, are the python scripts on the Pi which control the GPIOs in however fashion we like. From then on we are able to execute these commands via ssh from almost any device. Although, we want this process to be automated. In other words, the user doesn't have to enter credentials to ssh into the Pi but rather have the program automatically do so.
Luckily, this library allows us to do so. -> https://www.libssh.org/
There is nice documentation as to how to create ssh sessions and executing the commands that we want. So I won't go into much detail. Although I will comment on one procedure that the documentation recommends but gave me a problem.
When authenticating the user via password we use method ssh_userauth_password(ssh_session session, const char* username, const char* password). The documentation suggests setting the second parameter to NULL. Which was what was giving me the problem.
Simply change this to the login name you use when you normally ssh into the Raspberry Pi. For most the default name is "pi".
ssh_userauth_password(my_ssh_session, "pi", password);
I am using Python 2.7 and wifi library (https://wifi.readthedocs.org/en/latest/) on a Raspberry Pi. I have managed to install wifi library using:
sudo pip install wifi
on the terminal. The library seems to work but I can't figure out the way to connect to a wifi using a password. The documentation on the website is a bit difficult to understand, especially if you are a Python noob like me. I used this:
>>> from wifi import Cell, Scheme
>>> Cell.all('wlan0')
and I got all the wifi networks available and also the one I want to connect to called test1. So I am sure that the library works. I followed the steps on the website but got a permission denied error at:
>>> scheme.save()
Also, before that there was this command:
>>> scheme = Scheme.for_cell('wlan0', 'home', cell)
Does anyone know what that 'home' refer to? Is it the SSID name? Can anyone help me connect to a wifi called test1 whose password is passwordtest1? Is there any easier way to connect to wifi through terminal so as not to use Python?. Thanks in advance.
After some research, I didn't find a way to connect easily to a wifi using Python on a Raspberry Pi. So I solved my problem by using the wifi command on the Terminal:
sudo wifi connect --ad-hoc SSID_Name
Which automatically asks me for an input: passkey> .Where you can actually type the password, press enter and after that it automatically connects to the wifi. After that I can run my Python script which needs a connection to the internet in order to run. The wifi command is preferable to other terminal commands when it comes to my problem cause it needs less time to connect to a wifi manually. For example it is preferable to the process which uses this terminal command:
sudo nano /etc/network/interfaces
I hope this helps everyone who has the same problem.
My setup looks like this: A 64-bit box running Windows 7 Professional is connected to a Beaglebone running Angstrom Linux.
I'm currently controlling the beaglebone via a putty command line on the windows box.
What I'd like to do is run an OpenCV script to pull some vision information, process it on the windows box, and send some lightweight data (e.g a True or False, a triplet, etc.) over the (or another) USB connection to the beaglebone.
My OpenCV program is running using Python bindings, so any piping I can do with python would be preferable. I've played around with pyserial to receive data on a windows box via a COM port, so it seems like I could use that on the windows side... at a total loss though on the embedded linux front
Normally on the linux front, if the usb dongle is of the right type, you will see something like /dev/usbserial or similar device. Maybe check dmesg after plugging the cable.
(on linux you can run find /dev | grep usb to list all usb related devices)
Just a side note, I've seen the beaglebone has an ethernet port, why not just using a network socket? It's all easier than reinventing a protocol on usb.
If you want to use python, take a look o PyUSB, as you can see for example in Sending data via USB using PyUSB. A related post is PyUSB for the Raspberry Pi.