HI
Does anyone know how to get Serial Communications in rhyno python working in the rhino 5 python scripting.
Can anyone show me how to install pySerial library so that it is recognized in rhyno5 python .
thanks in advance.
HI
Does anyone know how to get Serial Communications in rhyno python working in the rhino 5 python scripting.
Can anyone show me how to install pySerial library so that it is recognized in rhyno5 python .
thanks in advance.
Hi @crouchorama,
If you choose Tools -> Options… In the Python editor (_EditPythonScript), you can see the manually-added default search paths.
Does this help?
– Dale
Hi Dale,
Thanks, yes I found the paths you have shown me but no, I don’t know what to do next In trying to install the module pySerial or any other module for that matter.
I’ve been trying a few things but I’m stumped.
whatever I’ve done I have got to the point where rhino5(32bit) now crashes every
time I try to open the python edit window in the rhino ide!
what I have done so far is download pySerial and intall it in both python 2.7 and python 3.5 both of which are installed on my computer, and it worked perfectly.
I used pip.exe to install a whl file to do this. however, there is no pip.exe in my iron python folders.
in fact there only seems to be two modules that can be imported : rhinoscriptsyntax.py and scriptcontext.py.
I tried copying pip.exe and pySerial into where the existing modules are in iron python and running from there but no luck
Here is my trainwreck:
C:\Users\david000\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib>python install pip3.5.exe pyserial-3.4-py2.py3-none-
any.whl
python: can’t open file ‘install’: [Errno 2] No such file or directory
C:\Users\xxxxxxxx\AppData\Roaming\McNeel\Rhinoceros\5.0\Plug-ins\IronPython (814d908a-e25c-493d-97e9-ee3861957f49)\settings\lib>pip3.5.exe install pyserial-3.4-py2.py3-none-any.whl
Requirement already satisfied: pyserial==3.4 from file:///C:/Users/xxxxxxxx/AppData/Roaming/McNeel/Rhinoceros/5.0/Plug-ins/IronPython%20%28814d908a-e25c-493d-97e9-ee3861957f49%29/settings/lib/pyserial-3.4-py2.py3-none-any.whl in c:\python35-32\lib\site-packages
It might help is you could tell me step by step how to install a module in rhyno python.
Thanks,
crouchorama
Hi @crouchorama,
Since you using IronPython, and IronPython is .NET based, you can certainly use the SerialPort class.
Does this help?
– Dale
HI
It’s a bit beyond me with my level of programming skills.
Could you show me how to install and import a module such as pySerial in rhyno?
Thanks
David
Hi @crouchorama,
In my brief testing, I have no had any luck getting it to work.
Why do you need it? What problem does it help you solve?
– Dale
I wrote this simple script to debug information from an Arduino using Serial class. It isn’t much more complicated than pySerial.
from System.IO.Ports import *
from Rhino import *
def Main():
# Create a new SerialPort object with default settings.
sp = SerialPort("COM3", 9600)
sp.Parity = Parity.None
sp.DataBits = 8
sp.StopBits = StopBits.One
sp.Handshake = Handshake.None
sp.DtrEnable = True
# Set the read/write timeouts
sp.ReadTimeout = 5000
sp.WriteTimeout = 5000
sp.DataReceived += Foo.sp_DataReceived
sp.Open()
_continue = True
while _continue:
message = ""
res, message = Input.RhinoGet.GetString("Type quit to exit loop", True, message )
if repr(message) == repr("quit"):
_continue = False
else:
RhinoApp.WriteLine(str(message))
#sp.WriteLine(
# String.Format("<{0}>", message));
sp.Close()
class Foo:
def sp_DataReceived(sender, e):
message = sender.ReadLine()
RhinoApp.Write(message)
sp_DataReceived = staticmethod(sp_DataReceived)
if __name__ == "__main__":
Main()