107-systems / CyphalPicoBase-CAN-firmware

Firmware for the OpenCyphalPicoBase board.
https://107-systems.org
MIT License
1 stars 0 forks source link

Add register API #15

Closed generationmake closed 1 year ago

generationmake commented 2 years ago

now compiling after https://github.com/107-systems/107-Arduino-Cyphal was fixed.

generationmake commented 2 years ago

hi @aentinger could you please check this. this should create a register list. maybe not in the best possible way but it should do it.

Nevertheless it is not working:

pi@raspberrypi:~ $ y -i 'CAN(can.media.socketcan.SocketCANMedia("can0",8),59)' rl 99 
Register list service is not accessible at node 99
null

any ideas? Thanks.

aentinger commented 2 years ago

Nothing comes to mind immediately. Possibly there could be something in the OpenCyphal Specification about what we are missing?

Also try and check the return value of respond:

  if (!node_hdl.respond(rsp, transfer.metadata.remote_node_id, transfer.metadata.transfer_id))
    Serial.println("respond failed");

@pavel-kirienko which error conditions would trigger the yakut output listed above?

generationmake commented 2 years ago

@aentinger were you able to take a look at this or do some tests one your own?

aentinger commented 2 years ago

@aentinger were you able to take a look at this or do some tests one your own?

Not yet, I'm trying to clean out the l3xz_io software first :bow: .

aentinger commented 2 years ago

Good Morning @generationmake :coffee: :wave:

I think I've fixed the register access issue. Can you please test?

Can you please also document the yakut commands you use for testing?

Note: I've been running a OpenCyphal network with 7 nodes and 1MBit/s + shoddy wiring on L3XZ and there are no problems (on the reception side). Also no glaring error was found during review of the service logic within 107-Arduino-Cyphal.

generationmake commented 2 years ago

Hi @aentinger I have tested with your latest software again and it is still not working! the yakut command is: y -i 'CAN(can.media.socketcan.SocketCANMedia("can0",8),59)' rl 99 the response is still

Register list service is not accessible at node 99
null
generationmake commented 2 years ago

could there be a conflict with the latest MCP2515 driver and that no more receive interrupts are generated?

aentinger commented 2 years ago

could there be a conflict with the latest MCP2515 driver and that no more receive interrupts are generated?

I've just re-checked, that should not be the case. Can you possibly test with a version prior that change, i.e. v1.3.4?

generationmake commented 2 years ago

Hi @aentinger I have checked with the previous and it also does not work. It seems like no interrupts are generated and no CAN messages are received by the controller. Serial output also shows nothing. Have you checked with your board?

pavel-kirienko commented 2 years ago

the yakut command is:

Protip: put this into l_drei_xz_slcan.sh:

# If no slcan ifaces exist in the system, try configuring them automatically
# using all connected Zubax Babel units.
if ! [ -e /sys/class/net/slcan0 ]; then
    # https://gist.github.com/pavel-kirienko/32e395683e8b7f49e71413aebf5e1a89
    sudo setup_slcan -r /dev/serial/by-id/usb-Zubax*Babel*
fi

# Set up the Cyphal/CAN configuration registers depending on which ifaces are up.
export UAVCAN__CAN__IFACE='socketcan:slcan0'
if [ -e /sys/class/net/slcan1 ]; then
    export UAVCAN__CAN__IFACE="$UAVCAN__CAN__IFACE socketcan:slcan1"
fi
export UAVCAN__CAN__MTU=8
export UAVCAN__CAN__BITRATE='1000000 1000000'

# Automatically find a free node-ID for all commands run in this session.
export UAVCAN__NODE__ID=$(yakut accommodate)
echo "Auto-selected node-ID for this session: $UAVCAN__NODE__ID"

Then use it like this:

source l_drei_xz_slcan.sh  # Do this once per terminal session.
y rl 99                    # Then just use Yakut as thou wilt.
aentinger commented 2 years ago

Have you checked with your board?

I'll check :+1:

Thank you @pavel-kirienko for the pro-tip :wink:

aentinger commented 2 years ago

Hi @generationmake :coffee: :wave:

I've broken my OpenCyphalPicoBase board :cry: . It never exposed a tty and now even via pressing BOOTSEL on power-up I can't restore the backup-upload mechanism via file storage.

Meanwhile, can you give a try to the register list command using a modified MCP2515 driver (see here https://github.com/107-systems/107-Arduino-MCP2515/pull/65 )? :pray:

aentinger commented 2 years ago

I've debugged the issue and I'm now reasonably sure the problem (amongst other ones, already solved ones: https://github.com/107-systems/107-Arduino-MCP2515/pull/66, https://github.com/107-systems/107-Arduino-MCP2515/pull/65) stems from the MCP2515 receive interrupt not being triggered anymore after a couple of CAN frames have been received (see https://github.com/107-systems/107-Arduino-MCP2515/issues/62, https://github.com/107-systems/107-Arduino-MCP2515/issues/53). I will need to continue looking into it.

aentinger commented 2 years ago

Hi @generationmake :coffee: :wave:

I believe I fixed your problem (https://github.com/107-systems/l3xz-fw_aux-controller/pull/15/commits/e93a8c04831605f207e8a12117f97da822209c8e). At least I can say with confidence that if fixed the same issue over here https://github.com/107-systems/107-Arduino-Cyphal/pull/158 .

generationmake commented 1 year ago

Hi @aentinger I did a short test and every thing seems to work now. Thanks for the good work! I will test harder and add some more registers and see how it performs.

generationmake commented 1 year ago

Hi @aentinger I think I made one subject-id-register writable and it seems to work. Unfortunately the 107-Arduino-Cyphal library does not support dynamic Subject-IDs. Do you have any idea how to proceed? Thanks.

aentinger commented 1 year ago

Unfortunately the 107-Arduino-Cyphal library does not support dynamic Subject-IDs. Do you have any idea how to proceed?

I have, but its the next step on the roadmap - after register API. See my comment here.

generationmake commented 1 year ago

Hi @aentinger I added registers to configure the update interval of the publish subject-ids. And I tried to set a lower limit of 100 on them: https://github.com/107-systems/l3xz-fw_aux-controller/blob/2fe74158ea5434129010a8b93c0c87f5dfbda7c3/l3xz-fw_aux-controller.ino#L214

The code works as expected and the limit is correctly set. However the Cyphal register value is not set correctly.

bernhard@notebookR60P-22:~$ y r -dd 99 aux.updateinterval.input0
natural16:                        
  value: [500]
_meta_: {mutable: true, persistent: false}
bernhard@notebookR60P-22:~$ y r -dd 99 aux.updateinterval.input0 5
natural16:                        
  value: [5]
_meta_: {mutable: true, persistent: false}
bernhard@notebookR60P-22:~$ y r -dd 99 aux.updateinterval.input0
natural16:                        
  value: [5]
_meta_: {mutable: true, persistent: false}

could you please check this? The value of the register should be 100.

Thanks

aentinger commented 1 year ago

You were in fact abusing the register-api in a way it was not designed :stuck_out_tongue_closed_eyes: . I've built a limit-functionality just for you and already pushed the changes to this fork.

generationmake commented 1 year ago

registers are implemented. code works as expected. will merge.