LoPy Using machine.main(filename)



  • Hi,

    anyone succesfull in using machine.main(filename) from boot.py.
    No matter what it always seems boot main.py.

    Runnig LoPy version 0.97.b1



  • @Rens said in LoPy Using machine.main(filename):

    Well just tested again with machine.main('test.py') and now its
    working as i would expect. Thanks again for the support.

    Rens

    Super! I'm glad that you finally did it! :o)



  • Well just tested again with machine.main('test.py') and now its
    working as i would expect. Thanks again for the support.

    Rens



  • Thanks for trying, no idea were I did go wrong.

    Will test and have another close look, as far is i can see
    both setup's are identical.

    When do find the answer I will post it here.

    Regards Rens



  • @Rens said in LoPy Using machine.main(filename):

    @rskoniec

    Still curious why this is not working, i assume when execfile('test.py')
    would return still will go on with main.py.

    Thanks for all suggestions !

    OK, as I promised I've tried my LoPy with boot.py as below:

    import machine
    import os
    
    uart = machine.UART(0, 115200)
    os.dupterm(uart)
    
    machine.main('test.py')
    

    with test.py file:

    print('Test')
    

    and everything is working as it should.

    0_1481018401638_main.jpg



  • @rskoniec

    Still curious why this is not working, i assume when execfile('test.py')
    would return still will go on with main.py.

    Thanks for all suggestions !



  • Thanks,

    just tested this and works like a charm.



  • @Rens Like @livius said, for your scenario execfile('your_file.py') is more appropriate - try it. Anyway machine.main('test.py') should do it's job too. Because my LoPys are at work, I'll try to check that tomorrow.



  • You do not need to override it to acomplish task
    use
    execfile('your file.py')
    in your boot.py



  • Thanks,

    tried this already in various syntax options,

    import machine
    import os
    uart = machine.UART(0, 115200)
    os.dupterm(uart)
    machine.main(test.py)
    or
    machine.main('test.py')
    or
    machine.main('./test.py')

    etc.

    Even removed main.py from the file system
    but no succes.

    The basic idea that want to implement is running various
    version of software depending in grounding pins.
    This is the first step i need to solve.



  • Default boot.py file looks like below:

    from machine import UART
    import os
    uart = UART(0, 115200)
    os.dupterm(uart)
    

    Try:

    import machine
    import os
    uart = machine.UART(0, 115200)
    os.dupterm(uart)
    machine.main(filename)
    

Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.