riot-appstore / PHiLIP

PHiLIP (Primitive Hardware In the Loop Integration Product) is qualified firmware used to perform simple hardware peripheral tests in a CI or by developers.
MIT License
25 stars 6 forks source link

Problems with example Code in ReadMe: Getting Started with CI Scripts #65

Open MarcelStenzel opened 4 years ago

MarcelStenzel commented 4 years ago

I had some problems while executing the Script. The syntax to calculate elapse_time was not correct since the 'data' key was not used. Then the DEBUG0 pin needs a pull-up resistor. Otherwise there were weird timings in the trace or the reset was toggled multiple times. The assert line would not succeed like this. I used the nucleo-f103rb Board for this.

This is the version of the code that worked for me:

from philip_pal import Phil

phil = Phil()
print("interface version: {}".format(phil.if_version))

# Reset philip to a clean state
assert phil.reset_mcu()['result'] == phil.RESULT_SUCCESS

# Setup DEBUG0 pin to log trace events with interrupt
for result in phil.write_and_execute('gpio[0].mode.io_type', 3):
    # Check each result for success
    assert result['result'] == phil.RESULT_SUCCESS

# Setup DEBUG0 pin to pullup
for result in phil.write_and_execute('gpio[0].mode.pull', 1):
    # Check each result for success
    assert result['result'] == phil.RESULT_SUCCESS

# Toggle the DUT_RST pin for the default period
phil.dut_reset()

# Toggle the DUT_RST pin for 1 second
phil.dut_reset(1.0)

trace = phil.read_trace()

# Assert the second toggle was in fact about 1 second
elapse_time = trace['data'][3]['time'] - trace['data'][2]['time']
assert elapse_time > 0.9 and elapse_time < 1.1

print("Trace Results")
print(trace)
MrKevinWeiss commented 4 years ago

Thanks, I will look into it!