Python Forum
Erreur Code access violation reading 0x00000004
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Erreur Code access violation reading 0x00000004
#1
Hello,

I code on the idle python version 3.8.3 and I receive this error message "OSError: exception: access violation reading 0x00000004" Angry Angry Angry that does not manage to resolve I went through all the functions in the imported library and I find not "canopenchannel" I think it is hidden and I do not have access
for information I use windows 7 professional.


from canlib import canlib, Frame
from canlib.canlib import ChannelData


def setUpChannel(channel=0,
                 openFlags=canlib.canOPEN_ACCEPT_VIRTUAL,
                 bitrate=canlib.canBITRATE_500K,
                 bitrateFlags=canlib.canDRIVER_NORMAL):
    ch = canlib.openChannel(channel, openFlags)
    print("Using channel: %s, EAN: %s" % (ChannelData(channel).device_name,
                                          ChannelData(channel).card_upc_no)
                                              )
    ch.setBusOutputControl(bitrateFlags)
    ch.setBusParams(bitrate)
    ch.busOn()
    return ch


def tearDownChannel(ch):
    ch.busOff()
    ch.close()


print("canlib version:", canlib.dllversion())

ch0 = setUpChannel(channel=0)
ch1 = setUpChannel(channel=1)

frame = Frame(id_=100, data=[1, 2, 3, 4], flags=canlib.canMSG_EXT)
ch1.write(frame)

while True:
    try:
        frame = ch0.read()
        print(frame)
        break
    except (canlib.canNoMsg) as ex:
        pass
    except (canlib.canError) as ex:
        print(ex)

tearDownChannel(ch0)
tearDownChannel(ch1)
error:

Traceback (most recent call last):
File "D:\Esss.py", line 25, in <module>
ch0 = setUpChannel(0)
File "D:\Esss.py", line 8, in setUpChannel
ch = canlib.openChannel(0,openFlags)
File "D:\Softs\lib\site-packages\canlib\canlib\channel.py", line 58, in openChannel
ch = Channel(channel, flags)
File "D:\Softs\lib\site-packages\canlib\canlib\channel.py", line 120, in __init__
self.handle = dll.canOpenChannel(channel_number, flags)
OSError: exception: access violation reading 0x00000004
>>>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pytest Installed, but VS Code Won’t Access Pytest AstralWeeks 9 2,888 Sep-13-2023, 03:00 PM
Last Post: AstralWeeks
  Erreur de code python sur un template rpm de zabbix samba 0 1,898 Apr-02-2021, 09:43 AM
Last Post: samba
  Code not reading http link from .txt file (Beginner level) plarrip 3 2,350 Dec-17-2020, 11:33 PM
Last Post: bowlofred
  Erreur Code yan_mhb 2 2,066 Jul-09-2020, 03:50 PM
Last Post: Larz60+
  -> Help: erreur print cherry_cherry 4 2,636 Apr-09-2020, 05:05 AM
Last Post: cherry_cherry
  Windows fatal exception: access violation czhhua28 0 5,870 Mar-11-2020, 01:53 AM
Last Post: czhhua28
  Cant find S3 Read or Write access from Python code tpc 0 2,343 Apr-19-2018, 04:00 AM
Last Post: tpc
  Error in running MS Access Database connection code pyuser1 4 7,574 Feb-01-2018, 08:28 PM
Last Post: pyuser1
  Help with code to access USB port donmerch 2 8,512 Jun-27-2017, 09:07 PM
Last Post: Ofnuts
  Why glGenVertexArray()gives access violation error? hsunteik 4 4,597 May-02-2017, 09:50 AM
Last Post: hsunteik

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020