wokwi / wokwi-cli

Wokwi Command Line Interface (for CI use cases)
MIT License
14 stars 5 forks source link

wait-serial with custom chip output #15

Open rafaelcorsi opened 2 months ago

rafaelcorsi commented 2 months ago

hello @urish !

overview: I created a custom chip that emulates the behavior of an I2C IMU, my idea is that I can check if students are correctly accessing the register bank to make settings on the sensor, or if they can read specific values and process them (with the aim of extracting information from the manual and implementing it correctly in code).

My original idea would be to put some printfs on the custom chip, when the student writes/reads and check this in test.yml with wait-serial, as illustrated below:

- wait-serial: '[chip-i2c-counter] mpu6050 write reg[0x6C]=128

But now I realized that wait-serial doesn't check the output of the custom chip, any suggestions on what we can do? Maybe create a wait-serial-custom-chip? Or add the custom chip log to the serial output?

The log is there, but we cant check!

image

urish commented 2 months ago

Hi Rafael!

I was actually thinking about a different mechanism:

Provide an API for chips to declare some kind of output variables, which will complement the "controls" that provide inputs to the chip.

For instance, a chip implementing a servo controller could declare an "angle" output variable, and then the tests could read this variable and assert on its value. And like controls, these output variables will only support floating point values (at least initially).

Would that also be useful for your use case?

rafaelcorsi commented 2 months ago

Hi! I think this is more complex than necessary because we will need to handle different variable types. What if the angle is a float, or what if it's an array? How would we check for these different kinds of data?

urish commented 2 months ago

Make sense - output variables may still be useful for more constrained use cases (e.g. angle of a servo), but I agree that just looking for a specific pattern in the chip output can be very useful.