I'm developing a Sublime Text plugin to work with IoT devices. Some of that hardwares have the option to upload the code by OTA (over the air) and I need to be able to discover the device by mDNS.
I've tried with zeroconf and it works very well, I just need to set the browser like that:
browser = ServiceBrowser(zeroconf, "_arduino._tcp.local.", listener)
So, what is the problem?
Sublime Text runs the plugins in it's own simplified version, so the only way to run an external package is downloading and integrating it into the plugin code. all is fine there, I've done with other packages without problem.
zeroconf has the following dependencies: enum-compat, netifaces, six and some of that dependencies has its own dependencies.
I tried downloading each dependency (and it seems to much code only to browse), but the main problem is that netifaces is written in C. I tested some things to try to make it work but I didn't make it.
I've also tried with this repository zeroconf It's and old version of the zeroconf above and not need the netifaces dependence. The code to browse is the same in both cases, but in this old version it's not getting any arduino device.
So what do I need?
I would like to get help with a code to browse/discover the arduino devices, as I previously described the main goal is get a minimum code to this task and run without install any dependence. I mean download the depedence if it needs and execute it locally.
I don't want someone to write me the code, but someone to may point me where can I start.
I've been looking the zeroconf code and it seems that it's not possible to work without netifaces, and that is the reason why the old repository didn't find the devices.
I've also tried with:
mdns This seems to be a non dependence code, but there is not documentation, so I didn't make it work
mdns-lookup It find other devices, but not the arduino/esp type
Related
I'm trying to run a face detection model in Unity. It gets input from the webcam, then spits out a face. But trying to make this work with C# has been an absolute nightmare. And despite all my suffering, I still haven't been able to make it work!
If I could use python, I'd be able to get it done easily. So, obviously, I want to find a way to get a python script working in Unity. But IronPython is the only thing I've been able to find, and it's outdated.
I need either knowledge of how to make IronPython work in spite of being outdated, or some other method. Please.
Unfortunately, Unity at this time does not support Python. Although, there is an asset that you can use a bit of Python with. I am not sure what you can do with this asset but I know it could help a minimal amount:https://assetstore.unity.com/packages/tools/integration/python-interpreter-645
Quick Note: Most programming languages work about the same way. If you figure out the documentation and grammar/punctuation for C#/UnityC#, you should be off just fine.
I try to use python once on Unity and I found a few ways:
There is a package call "IronPython" where you can add a python file to your unity project and then call a function from C# to your python code, to do that you should follow this:
We already know that we can use python to use .net internal calls.
Now we may use the same to start a console that can accept a scripting language in Unity engine.
To do this we have to include certain dll files.
These dll files must be present in Assets>plugins
IronPython.dll
IronPython.Modules.dll
Microsoft.Scripting.Core.dll
Microsoft.Scripting.dll
Microsoft.Scripting.Debugging.dll
Microsoft.Scripting.ExtensionAttribute.dll
Microsoft.Dynamic.dll
Once the Plugins are in place.
Initiate the Cs code
PythonEngine engine = new PythonEngine();
engine.LoadAssembly(Assembly.GetAssembly(typeof(GameObject)));
engine.ExecuteFile("Test.py");
Where test.py is the python code.
Initiate python side:
import UnityEngine from UnityEngine
import *
Debug.Log("Hello world from IronPython!")
References:
https://github.com/cesardeazevedo/Unity3D-Python-Editor
http://techartsurvival.blogspot.in/2013/12/embedding-ironpython-in-unity-tech-art.html
IronPython in Unity3D
the issue with this way is that most of the python module are not supported.
2.the second way is to create a file like json that contain the data you want to send to the json and then create an output json that send the output from the python script, this way is very limited with what you can send because the data must be contain in your json.
the last way that work for me is to install the Nuget package and copy the script from python to c# line by line with the relevent module installed in Unity and it's work for me, but copy a long code can take time.
this is a reference to the package:
https://github.com/GlitchEnzo/NuGetForUnity
and then to install the relevent package you should press on NuGet → Manage NuGet Packages and the choose the relevent package(for me it was Numpy and it work grate).
hope it will help you
I don't know how recent it is but there is a Unity package for python available on unity 2019.3 and further versions.
Warning the first versions of this package can't use Python3.
You can see more for yourself by the following link.
https://docs.unity3d.com/Packages/com.unity.scripting.python#2.0/manual/index.html
I hope this may help you.
We are thrilled to announce that Python for Unity 4.0.0-exp.5 is now available!
4.0.0-exp.5 is a major upgrade from our last public release, and incorporates a large number of changes. In summary:
Based on Python 3.7; scripts based on Python 2.7 will need to be ported.
Users no longer need to install Python on their system.
In-process Python is no longer reinitialized when the Unity domain reloads.
Removed the out-of-process API. The PySide example now runs in-process and is much simpler.
Limited support for a virtual environment workflow via the ProjectSettings/requirements.txt file.
Many bug fixes.
Documentation for the Python for Unity package is available here, and the full changelog can be found here.
This is an experimental release, and thus is not visible in Package Manager. To install this package, open Package Manager, click the + at the top left and select Add package by name.... Enter com.unity.scripting.python as the name and and 4.0.0-exp.5 as the version and click Add. Alternatively, you may edit Packages/manifest.json and add "com.unity.scripting.python": "4.0.0-exp.5", to the list of dependencies, or edit the existing entry for Python for Unity to update the version.
Soursce: https://forum.unity.com/threads/python-for-unity-release-announcements.1084688/
Documentation: https://docs.unity3d.com/Packages/com.unity.scripting.python#4.0/manual/index.html
Unity not supported python, But you Can write Python Code and run it by Socket programing, Create Server with python and send data,in C# Connect to server and use data sended with python.
Q: In creating a python distribution using setup.py, how can I define Python code that will be run by pip at installation time (NOT at build time!) and runs on the installation target machine (NOT on the build machine!)
I have spent the past seek searching the web for answers, reading contradictory documentation pages, and viewing multiple videos about setup.py. But in all this research can't find even one working example of how install time tasks can be specified.
Can someone point me at a complete working example?
Background: I am writing Python code for an application that is controlling a specialized USB peripheral my company is making, the processor where this will be installed is embedded/bundled with the peripheral and control software.
What's Needed: During the installation of the controlling application, I need the installing program (pip?) to write a configuration file on the install target machine. This file needs to include machine specific information about the target machine acquired using calls to functions imported from Lib/platform.py.
What I tried: Everything I've tried so far either runs at build time on the build machine (when setup.py runs and thus picks up the WRONG information for the target machine), or it merely installs the code I want to run on the target, but does not run it. It thus requires manual intervention by the user after the pip installation but prior to attempting to run the program they think they just installed, to run the auxiliary program that creates the installation config file. Only after this 2 step process can the user actually run the installed (and now properly configured) application.
Source code: Sorry. All my failed attempts to put functions in setup.py (which only run on the build machine, at build time) would only further confuse any readers and encourage more misleading wild goose chases down pointless rat holes.
If my users were sophisticated python developers who are comfortable with command line error messages, the link that #sinoroc has provided in the previous comment would have been an interesting solution.
Given that my users are barely comfortable installing packages from the App Store or Google Play store, the referenced work around is probably not right for me.
But given that install time functions are regarded as bad practice, my workaround is to alter the installed program so that its first action is to check for the presence of the necessary configuration file every time the program runs.
While this checking is seemingly unnecessary after the first run, it consumes only minimal CPU resources and would be more robust if the configuration file is ever accidentally deleted.
I am very unfamiliar with these low level setup instructions for open source circuit simulators. Basically, I want to be able to simulate a not too terribly complex circuit in Xyce. I am running Windows 10 and the instructions to download Windows 10 Xyce (cygwin, other dependencies, etc) are quite daunting. I came upon PySpice, and I know I am much more familiar with Python and how to install certain Python dependencies on Windows. Helping a total amateur out, if I have PySpice, do I still need to do a lot of Xyce/Ngspice installations? Or is basic simulation (netlist creation, AC sweeps) ready to go once I've installed PySpice?
I started by running a Linux VM to run Xyce more efficiently but ran into some issues and I just want to make sure there are no much better options before I jump full speed ahead into one option.
PySpice is the interface in Python to asset Ngspice commands. All these commands support for AC, DC, transient basic operation. It also supports the adjust the parameters in run time. The good part is to dynamic read back simulated node vectors and send to Python for backward process (connect to IoTs, SQL, Webhook, GPU acceleration..so on). It is the strength beyond current solution.
In my Ubuntu system, Ngspice is required to recompile and installed its library files. The user manual file had mentioned it. Xyce is not installed in my case.
below is my personal comments in using PySpice+Ngspice. This simulation engine is good for sure. The most difficult part is the GUI display coding(by QT4/QT5). Besides, need to spend time to make sure the schematic model (.cir) file is correct in some commercial package first. Otherwise, you hardly see any debug message under the multi-thread environment.
Summary: Using Ngspice+PySpice is still in my preference.
I've done tons of research on my issues, and I haven't really found an answer:
I'm trying to use Kivy in Eclipse on my computer. I've got an environment setup already, and I installed Kivy and the dependencies just like this:
https://kivy.org/docs/installation/installation-windows.html#
I copied the first bit of code from the tutorial on their site which should simply make a blank window, and upon running I got this error:
sdl2 - Exception: SDL2: Unable to load image
...
[CRITICAL ] [App ] Unable to get a Window, abort.
Just from that, I found tons of people with the same issue. issue 3002 on kivy's github (sorry, I can't put too many links) suggests solutions for linux users, which doesn't help me.
This: Trying to run KIVY, for the first time suggests installing pygame, which I've done multiple times, but it looks like the last update for pygame was in 2009? (I looked at their main site)
Either way, I installed pygame and that didn't change a thing. I also looked at issue 3491 (again, can't post more than 2 links) which seems very applicable but suggests downloading drivers from my GPU vendor, which I have no idea how to do, or what GPU I even have.
Is there any solution to my problem? Do I have to try and figure out how to get correct drivers? Also, I am using WinPython if that matters, but it seems to work for everything else...
Paste output of echo %PATH% here. Feel free to cut of personal things, I only want to know if sdl2 is available on the path (which I think is not). If not, add it. Should look like this:
<python.exe dir>\share\sdl2\bin
If it doesn't work for you, well... I'm still sure it's deps & path-related error. I usually annoy people with a link to my installer's github repo when I see similar error. I have there this line:
set PATH=%~dp0;%~dp0Tools;%~dp0Scripts;%~dp0share\sdl2\bin;%~dp0Lib\idlelib;%PATH%
Put <python dir>\Scripts on path too, because of garden, pip and other stuff.
I have had trouble setting up the pycharm ide on my macosx10.7 with python3..
I have scoured every resource available and tried hundreds of approaches, at this point I must accept my incompetence and seek help via this channel.
In my research, I notice a lack of ground-up explanations on python integration into macosx and how to configure pycharm to import modules, run code within the editor, etc. If i ever solve this I will make a very detailed tutorial.
I have imported python3 successfully, it looks like it is linked appropriately from /sys/lib/frameworks to /usr/lib ...etc -- version control is working just fine.
I think my issue is either in setting environmental variables (tried the program to fix this and tried macports) and in the script needed to execute. it will catch errors throughout but final product does not run in python and returns printout of :
/Library/Frameworks/Python.framework/Versions/3.2/bin/python3.2 /Users/anon/Desktop/pythonpractice/Py_Ex/classes.py
Process finished with exit code 0
i really need to get this configuration sound for my python programming class. please help (I've been through every line of pycharm website) .. preferably is there a way to map it via terminal? thanks for anyone who took the time to read this.
Summary of the discussion above:
Python 3.2.2 installation was broken on this Mac, installing ActiveState Python 3.2.2 from scratch and configuring it in PyCharm has fixed the problem.
Python path to be used in PyCharm settings: /Library/Frameworks/Python.framework/Versions/3.2/bin/python3
Incompatible third-party plug-ins may break PyCharm, uninstall/disable them in Preferences | Plugins.
Ensure the latest PyCharm version is installed.
User's code depends on the graphics.py module which was not in the project or in the PYTHONPATH. Putting it into the project has solved the problem.
Most likely the wrong Run/Debug configuration was used in PyCharm, the easiest way to run or debug such scripts is by using the editor context menu Run and Debug actions. PyCharm creates the configuration automatically and debugging works fine as shown of the screenshot:
If one wants to configure and debug it, he can use the code.zip file to get started.
Sorry for the comments mess above, but it was not possible to move it into chat as user had only 1 reputation point, hence not able to use the chat feature of StackOverflow.