Giter VIP home page Giter VIP logo

Comments (15)

pelikhan avatar pelikhan commented on July 28, 2024

from pxt-ev3.

pelikhan avatar pelikhan commented on July 28, 2024

Looks like we should mock this line

let conns = analogMM.slice(AnalogOff.InConn, DAL.NUM_INPUTS)

When an device api gets called, it should register itself in the InConn array so that it becomes visible to the simulator. This might need to be an Async operation where you have to wait that the device gets detected on first use.

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

I'll keep digging, but Peli like I said, in order for that method (analogMM.slice) to return the list of connected devices it needs to know the list in advance, and there's a dependency on any functional API, like a colorSensor.color to know that there is a color sensor connected on port X, otherwise it won't call the VM. and in turn won't call the sim methods (that could potentially indicate to us that theres a color sensor on port X)

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

I guess we can always return a CONN_INPUT_UART. Except touch is not uart, so donno how we'll detect that.

from pxt-ev3.

pelikhan avatar pelikhan commented on July 28, 2024

When the code calls “colorSensor.color”, it registers the device state and returns the default value. Later on the device gets polled and UartSensor picks up the value.
So it might be that the first read returns the default value.

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

Figured it out. Added a method in the cpp (motorUsed and sensorUsed) and in the constructor of every Sensor and Motor I call markUsed.
markUsed is in turn implemented in the simulator and is a NOP in the cpp. Seems to work :)

from pxt-ev3.

pelikhan avatar pelikhan commented on July 28, 2024

How do you handle collisions?

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

Not sure yet. but we'll need to figure out some clever way to do so. At least we now have all the information.

from pxt-ev3.

pelikhan avatar pelikhan commented on July 28, 2024

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

Yeah, although unlikely, the common scenario is to use event handlers and different ports. All the logic is in the sim, so we can certainly have a timestamp associated with registration and perhaps have a "smarter" way to tell which of two colliding inputs / outputs to discard.

from pxt-ev3.

pelikhan avatar pelikhan commented on July 28, 2024

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

Okay. Can do.

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

This is all in sim, so perhaps we can even handle it in some nice way. Pop up a message or something.

from pxt-ev3.

pelikhan avatar pelikhan commented on July 28, 2024

from pxt-ev3.

samelhusseini avatar samelhusseini commented on July 28, 2024

Yup! thanks!

from pxt-ev3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.