[IronPython] Accessing Serial Port from IronPython driven Webpage
dinov at microsoft.com
Thu Aug 26 02:40:27 CEST 2010
> Hi All
> I wonder if anyone has tried to access the serial port from a web app
> using Iron Python. I have a simple default webpage which is using
> IronPython as the code behind. My 'FanOn' function calls a little
> IronPython script that opens up the serial port and sends an ZigBee
> communications packet to a little home made device which would then
> a fan on.
> I have found a web page that describes how to access the Serial port on
> the server using C#:
> But I don't know how to translate this into IronPython. In my FanOn
> function I have:
> sx = SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
> after importing System.Security.Permissions
> However I don't know how to decorate the function itself with:
> Any ideas would be greatly appreciated.
Do you need all of the security goo? My guess would be that all of this
isn't necessary. It should only be necessary if you're running in a partial
trust scenario where your assembly is capable of asserting permissions. That
could be the case if you're in ASP.NET's medium trust. Otherwise it should
make no difference.
If you do need this you may be unable to do this w/ IronPython. The assert
is associated with a stack frame and we'll actually perform the call to
assert inside of another method, unwind the stack, and then it'll be gone.
My best guess is you'd need to have a C# wrapper for this to work from partial
trust in ASP.NET.
More information about the Ironpython-users