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 turn a fan on.

I have found a web page that describes how to access the Serial port on the server using C#:

http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/a5ff20cf-0bb5-4a3e-aed4-24c6290f66cd/

But I don't know how to translate this into IronPython. In my FanOn function I have:

sx = SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
sx.Assert()

after importing System.Security.Permissions

However I don't know how to decorate the function itself with:

[SuppressUnmanagedCodeSecurityAttribute()]

Any ideas would be greatly appreciated.

Kind regards,

Kurt

PS A simplified version of my FanOn script which is containined in a Default.aspx.py file behind Default.aspx:

def FanOn(sender, e):
    sx = SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
    sx.Assert()
    sp = serial_ports.port('COM4')
    sp.open()
    sp.write_packet('7E001017060013A20040645580FFFE024431053B')
    sp.close()
    lblResponse.Text = "Fan successfully turned on"


_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to