# Error in simple script

**URL:** <https://forum.opencyphal.org/t/error-in-simple-script/598>\
**Category:** PyCyphal\
**Created:** [August 19, 2019, 7:39pm UTC](https://forum.opencyphal.org/t/error-in-simple-script/598 "2019-08-19T19:39:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malis](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/m/9e8a1a/32.png) [@Malis](https://forum.opencyphal.org/u/Malis)\
**Post date:** [August 19, 2019, 7:39pm UTC](https://forum.opencyphal.org/t/error-in-simple-script/598/1 "2019-08-19T19:39:25Z")

</div>

Hi guys,

With the following script

```auto
  # Hello World program in Python
import uavcan

# Instantiating an instance of standard service type uavcan.protocol.GetNodeInfo
# Here we need the response data structure, which is why we use the factory Response()
node_info = uavcan.protocol.GetNodeInfo.Response()
node_info.name = 'org.uavcan.pyuavcan_demo'
node_info.software_version.major = 1
node_info.hardware_version.unique_id = b'100' # Setting first 5 bytes; rest will be kept zero
# Fill other fields as necessary...

node = uavcan.make_node('can0',
                        node_id=100, # Setting the node ID 123
                        node_info=node_info) # Setting node info

def perform_other_tasks():
    print('Periodic')
    handle = node.add_handler(uavcan.protocol.NodeStatus, node_status_callback)

def node_status_callback(event):
    print('NodeStatus message from node', event.transfer.source_node_id)
    print('Node uptime:', event.message.uptime_sec, 'seconds')
    # Messages, service requests, service responses, and entire events
    # can be converted into YAML formatted data structure using to_yaml():
    print(uavcan.to_yaml(event))
    
while True:
    try:
        node.spin(1) # Spin for 1 second or until an exception is thrown
        perform_other_tasks()
        # time.sleep(0.1) # Never do this!
    except UAVCANException as ex:
        print('Node error ********************************************** :', ex)

```

I get the following error

> Traceback (most recent call last):  
> File “test.py”, line 29, in   
> node.spin(1) # Spin for 1 second or until an exception is thrown  
> File “/usr/local/lib/python3.7/dist-packages/uavcan/node.py”, line 414, in spin  
> execute\_once()  
> File “/usr/local/lib/python3.7/dist-packages/uavcan/node.py”, line 410, in execute\_once  
> self.\_recv\_frame(frame)  
> File “/usr/local/lib/python3.7/dist-packages/uavcan/node.py”, line 314, in \_recv\_frame  
> transfer.from\_frames(transfer\_frames)  
> File “/usr/local/lib/python3.7/dist-packages/uavcan/transport.py”, line 781, in from\_frames  
> raise TransferError(“Toggle bit value {0} incorrect on frame {1}”.format(tail & 0x20, idx))  
> uavcan.transport.TransferError: Toggle bit value 0 incorrect on frame 1
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):  
> File “test.py”, line 32, in   
> except UAVCANException as ex:  
> NameError: name ‘UAVCANException’ is not defined

I have to admit that I’m a beginner, so any help is appreciated.  
Any idea?

Best regards,

Malis

---

<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 21, 2019, 2:28pm UTC](https://forum.opencyphal.org/t/error-in-simple-script/598/2 "2019-08-21T14:28:59Z")

</div>

Replace `UAVCANException` with `uavcan.UAVCANException`.
