# Using Pyuavcan on Windows

**URL:** <https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903>\
**Category:** PyCyphal\
**Created:** [August 4, 2020, 12:06pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903 "2020-08-04T12:06:42Z")\
**Posts on this page:** 9\
**Page:** 2

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 11, 2020, 9:34am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/21 "2020-08-11T09:34:42Z")

</div>

Can you please step through the reception pipeline with a debugger to see where your frames are being dropped? It makes sense to add some debug logging here as well.

---

<div class="post-metadata">

**Author:** ![polaris](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/7ab992/32.png) [@polaris](https://forum.opencyphal.org/u/polaris)\
**Post date:** [August 11, 2020, 10:01am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/22 "2020-08-11T10:01:09Z")

</div>

Debug logging with “-vv” doesn’t show any INFO, DEBUG or ERROR messages during receiving these packets, at the end there are also no in\_frames or in\_frames\_errored in the stats output. They are probably lost between can and media I guess.

P.S. Sorry, I found it, it was the handler of Media.ReceivedFramesHandler, trying to fix it

---

<div class="post-metadata">

**Author:** ![polaris](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/7ab992/32.png) [@polaris](https://forum.opencyphal.org/u/polaris)\
**Post date:** [August 11, 2020, 11:32am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/23 "2020-08-11T11:32:32Z")

</div>

One more question, please.  
Frames are processed properly now, uvc pub is working, uvc call has some problems with implementation:

> uvc call 42 uavcan.node.GetInfo.1.0 “{}” --tr=“CAN(can.media.pythoncan.PythonCANMedia(‘pcan’,‘PCAN\_USBBUS1’,8),10)”
> 
> 2020-08-11 13:28:33 8460 ERROR pyuavcan.\_cli.commands.call: The transport implementation is misbehaving: feedback was never emitted; falling back to software timestamping. Please submit a bug report. Involved instances: client=Client(dtype=‘uavcan.node.GetInfo.1.0’, input\_transport\_session=CANInputSession(InputSessionSpecifier(data\_specifier=ServiceDataSpecifier(service\_id=430, role=\<Role.RESPONSE: 2\>), remote\_node\_id=42), PayloadMetadata(data\_type\_hash=0x6666666630239d01, max\_size\_bytes=313))), result=(uavcan.node.GetInfo.Response.1.0(protocol\_version=uavcan.node.Version.1.0(major=1, minor=0), hardware\_version=uavcan.node.Version.1.0(major=1, minor=0), software\_version=uavcan.node.Version.1.0(major=0, minor=1), software\_vcs\_revision\_id=0, unique\_id=[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], name=‘our-servo’, software\_image\_crc=, certificate\_of\_authenticity=‘’), TransferFrom(timestamp=Timestamp(system\_ns=1597145313213994200, monotonic\_ns=21869359000000), priority=\<Priority.NOMINAL: 4\>, transfer\_id=2, fragmented\_payload=[\<memory at 0x0000021AD1A2E048\>, \<memory at 0x0000021AD1A2E108\>, \<memory at 0x0000021AD1A2E1C8\>, \<memory at 0x0000021AD1A2E288\>, \<memory at 0x0000021AD1A2E348\>, \<memory at 0x0000021AD1A2E408\>], source\_node\_id=42))

Where have I to search for a problem? I don’t see any dependencies to on\_transfer\_feedback in my python-can implementation.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 11, 2020, 11:36am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/24 "2020-08-11T11:36:16Z")

</div>

The library requested the transport to report when the transfer is delivered to the underlying network driver, but the report never arrived. Therefore, the transport is misbehaving. The error comes from this place specifically:

> <https://github.com/UAVCAN/pyuavcan/blob/1d5dbf07b6acc64576ca4f1deaae3b35bd7df377/pyuavcan/_cli/commands/call.py#L152>

This is where the caller requested the transport to invoke the transmission feedback handler. Your implementation does not appear to handle it correctly.

---

<div class="post-metadata">

**Author:** ![polaris](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/7ab992/32.png) [@polaris](https://forum.opencyphal.org/u/polaris)\
**Post date:** [August 11, 2020, 12:57pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/25 "2020-08-11T12:57:51Z")

</div>

Thank you for your reply. I have already seen this part of code, I can’t just bind it with media layer.

I have found **loopback** parameter in **\_parse\_native\_frame** function only, it is set if own transmitted packet was received successfully.

But I can’t find any connection between **client.output\_transport\_session.enable\_feedback(on\_transfer\_feedback)**  
and **pyuavcan.transport.can.media.DataFrame** :  
[https://github.com/UAVCAN/pyuavcan/blob/1d5dbf07b6acc64576ca4f1deaae3b35bd7df377/pyuavcan/transport/can/media/\_frame.py#L19](https://github.com/UAVCAN/pyuavcan/blob/1d5dbf07b6acc64576ca4f1deaae3b35bd7df377/pyuavcan/transport/can/media/_frame.py#L19)

I think it is the last thing I need to get the implementation ready. Actually I can work with a current version already, if you don’t need python-can, then I will stop annoying you.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 11, 2020, 1:23pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/26 "2020-08-11T13:23:50Z")

</div>

The feedback flag is passed down the transfer serializer here:

> <https://github.com/UAVCAN/pyuavcan/blob/1d5dbf07b6acc64576ca4f1deaae3b35bd7df377/pyuavcan/transport/can/_session/_output.py#L126>

The serializer returns a generator of [UAVCANFrame](https://github.com/UAVCAN/pyuavcan/blob/1d5dbf07b6acc64576ca4f1deaae3b35bd7df377/pyuavcan/transport/can/_frame.py#L20), where the first frame has the `loopback` flag set.

Upon seeing a frame where `loopback` is true/false, the SocketCAN driver enables/disables the corresponding socket option:

> <https://github.com/UAVCAN/pyuavcan/blob/1d5dbf07b6acc64576ca4f1deaae3b35bd7df377/pyuavcan/transport/can/media/socketcan/_socketcan.py#L219-L222>

You need to recreate the loopback enable/disable logic in your media driver.

---

<div class="post-metadata">

**Author:** ![polaris](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/7ab992/32.png) [@polaris](https://forum.opencyphal.org/u/polaris)\
**Post date:** [August 12, 2020, 1:44pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/27 "2020-08-12T13:44:52Z")

</div>

Hello Pavel, I couldn’t implement it really tidy, python-can probably doesn’t receive transmitted messages, so I have just pushed a loopback message to an array and then place it to a normal receive buffer. Now everything works perfectly with Windows.

Should I commit my implementation or is it not good enough?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 12, 2020, 4:07pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/28 "2020-08-12T16:07:06Z")

</div>

Send a pull request, please, we’ll give it a look. Also, I think it would benefit everyone if you informed the maintainers of Python-CAN about the need for supporting loopback frames. Maybe you could just open a ticket or something?

Thanks!

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [December 8, 2020, 1:05pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/29 "2020-12-08T13:05:10Z")

</div>

> [@polaris](#):
>
> Thank you, double quotes have solved the problem! But why?

Incidentally, I just found out that Windows shell does not support single-quoted string literals. The only valid syntax is double-quote: `"{}"`, whereas `'{}'` is parsed differently. I don’t really use Windows (other than in CI pipelines) so I wasn’t aware of this until now.

[Previous page](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903.md?page=1)
