# 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:** 20\
**Page:** 1

<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 4, 2020, 12:06pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/1 "2020-08-04T12:06:42Z")

</div>

Hello, is it at the moment possible to use Pyuavcan library on a Windows PC? I have tried to install it and found out, that usage of python-can library is not implemented yet. I have some CAN adapters (Kvaser and Peak) but probably can’t use them to connect to a pyuavcan script. Is there any solution for Windows users?

---

<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 4, 2020, 4:47pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/2 "2020-08-04T16:47:59Z")

</div>

> [@polaris](#):
>
> is it at the moment possible to use Pyuavcan library on a Windows PC?

Yes, but not with CAN. The library is continuously tested against Windows and is known to work there. The problem is that the only CAN bus media backend implementation we have at the moment – that is, SocketCAN – works only under GNU/Linux.

We need someone to help us get it working on Windows by writing the glue logic between the PyUAVCAN transport model and the Python-CAN library. Can you lend us a hand here?

_(we chatted with you on Habr didn’t we?)_

---

<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 5, 2020, 10:09am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/3 "2020-08-05T10:09:33Z")

</div>

Hello, yes, we had a conversation on Habr.  
I will try to add python-can support but I’m not a big Python expert, so it needs time to understand the structure.

---

<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 6, 2020, 8:20am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/4 "2020-08-06T08:20:48Z")

</div>

_Ref: Pyuavcan 1.1.0.dev1, Windows 10, Python 3.7.7, CAN/python-can._

Hello again, I have started to implement python-can support, it seems to throw no errors now, but I have some other issues.

I would like to get some kind of communication and used some commands from the manual, but it didn’t work. I am pretty sure it’s not a problem of the transport layer, because the error message gives some info about the problem:

> ```
> uvc call 42 --tr="CAN(can.media.pythoncan.PythonCANMedia('pcan','PCAN_USBBUS1',8),10)" uavcan.node.GetInfo.1.0 '{}'
> 
> Error: ValueError: dictionary update sequence element #0 has length 1; 2 is required
> 
> ```

Probably something is wrong with the structure of the command, but I have just copied it from the manual and don’t see any errors there.

Could you please give me some explanation about the error?

---

<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 6, 2020, 9:44am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/5 "2020-08-06T09:44:28Z")

</div>

> [@polaris](#):
>
> Could you please give me some explanation about the error?

Errors from the string-to-object conversion logic are always fun. The readability issue is tracked at [Improve error messages in pyuavcan.dsdl.update\_from\_builtin() · Issue #116 · OpenCyphal/pycyphal · GitHub](https://github.com/UAVCAN/pyuavcan/issues/116).

I can’t reproduce your problem if I just copy-paste the string from your post replacing the transport specification with vcan0:

```auto
uvc call 42 --tr="CAN(can.media.socketcan.SocketCANMedia('vcan0',8),10)" uavcan.node.GetInfo.1.0 '{}'
The request has timed out after 1.0 seconds

```

But if I replace the ASCII quotes with fancy Unicode quotes, I get your error:

```auto
uvc call 42 --tr="CAN(can.media.socketcan.SocketCANMedia('vcan0',8),10)" uavcan.node.GetInfo.1.0 ”{}”
Error: ValueError: dictionary update sequence element #0 has length 1; 2 is required

```

---

<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 6, 2020, 10:06am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/6 "2020-08-06T10:06:11Z")

</div>

No, these are definitely not Unicode symbols, I have checked the string with a Hex-editor, the code for this quote is #27.

Here is a screenshot with the message:

 ![uavcan_error](https://forum.opencyphal.org/uploads/default/original/1X/68be433d4ba03922a1eb182b67de87d796754744.png)

Please ignore messages about CAN filters, I haven’t implemented them yet.

---

<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 6, 2020, 10:09am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/7 "2020-08-06T10:09:53Z")

</div>

Can you please run it with `-vv` (V for Verbose, twice for extra) like `uvc -vv pub ...` so that we could see the stack trace?

---

<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 6, 2020, 10:39am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/8 "2020-08-06T10:39:30Z")

</div>

Yes, sure, here is the log:  
[error\_log.txt](https://forum.opencyphal.org/uploads/short-url/rqRAYEqkbHCUTCYZxR7cP16yRpn.txt) (8.8 KB)

---

<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 6, 2020, 10:46am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/9 "2020-08-06T10:46:41Z")

</div>

Sorry, it was actually the screenshot for the second problem from another thread, here is the screenshot with dictionary parameters:

 ![uavcan_error2](https://forum.opencyphal.org/uploads/default/original/1X/6cd559bc9777c10d6cd4434782c620fb1e995528.png)

And the corresponding log:  
[error\_log2.txt](https://forum.opencyphal.org/uploads/short-url/j1oQoCf08IO48FhZXdxmbDR9iud.txt) (9.2 KB)

---

<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 6, 2020, 10:56am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/10 "2020-08-06T10:56:24Z")

</div>

Okay this is getting interesting. Let’s see if you can reproduce the problem in isolation from your custom media driver because I can’t. Please run the following and make sure you don’t get any errors (you will get warned about a node-ID conflict but that’s because the node sees its own reflection in the Loopback transport):

```nohighlight
[pavel@deep-thought demo]$ uvc call 42 --tr="Loopback(123)" uavcan.node.GetInfo.1.0 '{}'
2020-08-06 13:53:49 90329 WARNING pyuavcan.application.heartbeat_publisher: NODE-ID CONFLICT: There is another node on the network that uses the same node-ID 123. Its latest heartbeat is uavcan.node.Heartbeat.1.0(uptime=0, health=0, mode=0, vendor_specific_status_code=90329) with transfer metadata TransferFrom(timestamp=Timestamp(system_ns=1596711229162567409, monotonic_ns=232711769237893), priority=<Priority.NOMINAL: 4>, transfer_id=0, fragmented_payload=[<memory at 0x7fe88aaccb80>], source_node_id=123)
The request has timed out after 1.0 seconds

```

**Edit:** also please try moving the `--tr=...` argument towards the end of the string.

---

<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 6, 2020, 11:19am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/11 "2020-08-06T11:19:08Z")

</div>

Still the same message:

```nohighlight
uvc call 42 uavcan.node.GetInfo.1.0 '{}' --tr="Loopback(123)"
Error: ValueError: dictionary update sequence element #0 has length 1; 2 is required

```

---

<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 6, 2020, 12:35pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/12 "2020-08-06T12:35:31Z")

</div>

Maybe you could try double quotes or launch a debugger to see the context where the error occurs? This is not reproducible on my end.

---

<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 6, 2020, 1:49pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/13 "2020-08-06T13:49:15Z")

</div>

Thank you, double quotes have solved the problem! But why?

---

<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 6, 2020, 2:01pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/14 "2020-08-06T14:01:35Z")

</div>

No idea. Why don’t we just blame Microsoft for this?

---

<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 7, 2020, 11:55am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/15 "2020-08-07T11:55:44Z")

</div>

Hello, I could finally finish a raw python-can implementation that seems to work.  
I can see packets with my CAN adapter and don’t find any problems there, but simple GetInfo request stays unanswered for the pyuavcan. Could you please take a look at the following log?

> uvc call 42 --tr=“CAN(can.media.pythoncan.PythonCANMedia(‘pcan’,‘PCAN\_USBBUS1’,8),10)” uavcan.node.GetInfo.1.0 “{}”
> 
> Set filters: [{‘can\_id’: 33555712, ‘can\_mask’: 41959296, ‘extended’: True}, {‘can\_id’: 10, ‘can\_mask’: 8388735, ‘extended’: True}, {‘can\_id’: 8213760, ‘can\_mask’: 50331520, ‘extended’: True}]  
> TX: Timestamp: 0.000000 ID: 107d550a X DLC: 8 00 00 00 00 00 7f 02 e0  
> TX: Timestamp: 0.000000 ID: 136b950a X DLC: 1 e2  
> RX: Timestamp: 23127.501678 ID: 126b852a X DLC: 8 01 00 01 00 00 01 00 a2  
> RX: Timestamp: 23127.501971 ID: 126b852a X DLC: 8 00 00 00 00 00 00 00 02  
> RX: Timestamp: 23127.502262 ID: 126b852a X DLC: 8 01 00 00 00 00 00 00 22  
> RX: Timestamp: 23127.502555 ID: 126b852a X DLC: 8 00 00 00 00 00 00 00 02  
> RX: Timestamp: 23127.502830 ID: 126b852a X DLC: 8 00 00 0a 76 6f 6c 7a 22  
> RX: Timestamp: 23127.503105 ID: 126b852a X DLC: 8 2d 73 65 72 76 6f 00 02  
> RX: Timestamp: 23127.503297 ID: 126b852a X DLC: 3 8b fc 62  
> RX: Timestamp: 23128.051938 ID: 107d552a X DLC: 8 48 a6 0c 00 00 00 00 fc  
> TX: Timestamp: 0.000000 ID: 107d550a X DLC: 8 01 00 00 00 00 7f 02 e1  
> The request has timed out after 1.0 seconds  
> Set filters: [{‘can\_id’: 33555712, ‘can\_mask’: 41959296, ‘extended’: True}, {‘can\_id’: 10, ‘can\_mask’: 8388735, ‘extended’: True}]  
> RX: Timestamp: 23129.054787 ID: 107d552a X DLC: 8 30 aa 0c 00 00 00 00 fd

I guess that fields **software\_image\_crc** and **certificate\_of\_authenticity** are optional and must not be added to an answer?  
Thank you in advance!

---

<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 7, 2020, 5:38pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/16 "2020-08-07T17:38:05Z")

</div>

I can’t immediately see any issues here. How the answering node (whose node-ID is 10 here) is implemented? Have you tried looking at verbose logs (`-vv`)?

> [@polaris](#):
>
> I guess that fields **software\_image\_crc** and **certificate\_of\_authenticity** are optional and must not be added to an answer?

Correct.

---

<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 10, 2020, 5:48am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/17 "2020-08-10T05:48:38Z")

</div>

May be I understand the purpose of the pyuavcan wrong, but I thought it has to implement the node with node-ID 10.  
I mean I have started pyuavcan with CAN as transport layer, **pcan** as CAN adapter and 10 as node-ID with this parameter:

> –tr=“CAN(can.media.pythoncan.PythonCANMedia(‘pcan’,‘PCAN\_USBBUS1’,8),10)”

And then I try to get info from a node with node-ID 42 using:

> call 42 uavcan.node.GetInfo.1.0 “{}”

Or is this suppose wrong? Does pyuavcan act as a real UAVCAN node?

---

<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 10, 2020, 4:19pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/18 "2020-08-10T16:19:31Z")

</div>

I have some more info now. I have installed the library on a Linux PC and it is works there as I supposed. uvc works as a UAVCAN-node, sends/receives messages and **displays** them!  
So there is probably a problem with Windows support. I am pretty sure the part I wrote sends and receives messages via python-can (I have shown the logs here and I see these messages with a sniffer), so the problem is on the side of handling messages that were received.  
I will check it once more and write here again.

---

<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 10, 2020, 7:58pm UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/19 "2020-08-10T19:58:08Z")

</div>

> [@polaris](#):
>
> May be I understand the purpose of the pyuavcan wrong, but I thought it has to implement the node with node-ID 10.

Yes. Sorry, you are correct here. I meant to ask about node 42, not 10. Is it the demo app from the documentation?

> [@polaris](#):
>
> I will check it once more and write here again.

Please do. Also don’t forget to check verbose logs (`-vv` or just set the environment variable [`PYUAVCAN_LOGLEVEL=debug`](https://pyuavcan.readthedocs.io/en/latest/pages/api.html#log-level-override)).

---

<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, 8:58am UTC](https://forum.opencyphal.org/t/using-pyuavcan-on-windows/903/20 "2020-08-11T08:58:56Z")

</div>

Hello again, I have had some issues with timestamps, now it seems to be everything ok. But I have no messages from pyuavcan script anyway. Linux version works good, but Windows version with python-can doesn’t work properly, I think the problem is not the python-can support from my side. Here is the log for the Win version and my UAVCAN node running with ID 42 (I just print TimestampedDataFrame):

> uvc sub uavcan.node.Heartbeat.1.0 --tr=“CAN(can.media.pythoncan.PythonCANMedia(‘pcan’,‘PCAN\_USBBUS1’,8),10)”  
> 2020-08-11T10:48:59.383532/12295.546000000: 0x107d552a 80 41 bb 00 00 00 00 ef ‘.A…’  
> 2020-08-11T10:49:00.386530/12296.546000000: 0x107d552a 68 45 bb 00 00 00 00 f0 ‘hE…’  
> 2020-08-11T10:49:01.389677/12297.546000000: 0x107d552a 50 49 bb 00 00 00 00 f1 ‘PI…’

and so on.  
And here is the Linux log for the same node:

> uvc sub uavcan.node.Heartbeat.1.0 --tr=“CAN(can.media.socketcan.SocketCANMedia(‘can0’,8),111)”  
> 2020-08-11T10:23:57.996792/9309.854723523: 0x107d552a d8 69 a4 00 00 00 00 f6 ‘.i…’
> 
> 32085:  
> uptime: 10775000  
> health: 0  
> mode: 0  
> vendor\_specific\_status\_code: 0
> 
> 2020-08-11T10:23:58.999695/9310.857592968: 0x107d552a c0 6d a4 00 00 00 00 f7 ‘.m…’
> 
> 32085:  
> uptime: 10776000  
> health: 0  
> mode: 0  
> vendor\_specific\_status\_code: 0
> 
> 2020-08-11T10:24:00.002547/9311.860905444: 0x107d552a a8 71 a4 00 00 00 00 f8 ‘.q…’
> 
> 32085:  
> uptime: 10777000  
> health: 0  
> mode: 0  
> vendor\_specific\_status\_code: 0

As you see, same data, similar timestamps, but I get the info I need.  
What could be a reason for such a behavior?

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