Ich möchte über eine PCMCIA Karte auf den Can Bus gucken. Die Firma liefert zu der Karte auch eine Bibliothek mit. Natürlich ist das alles in C geschrieben. Hier gibts eine von vielen Anleitungen.
Was ich bisher geschafft hab:
Code: Alles auswählen
import ctypes
from ctypes import*
CanCard_id=c_int(15) #Diese Werte kommen aus einer mit
gChannel=c_int(0) #gelieferten .h Datei wobei 15 für den
PermissionMask=c_int(0) #Kartentyp steht
candll = ctypes.windll.LoadLibrary("vcand32.dll") #die dll wird geladen
candll.ncdOpenDriver()
gChannelMask = candll.ncdGetChannelMask(CanCard_id,c_int(0),gChannel)
vErr = candll.ncdOpenPort(gPortHandle,"CanBus",gChannelMask,gChannelMask,PermissionMask,128);
Die Anleitung der Firma selbst sagt:
2.2.7 ncdOpenPort
Syntax :
- Vstatus ncdOpenPort (
VportHandle *portHandle,
char *userName,
Vaccess accessMask,
Vaccess initMask,
Vaccess *permissionMask,
int rxQueueSize)
Name
- Description
- Pointer to a variable where the port handle isreturned. This handle must be used for any further calls to the port. If -1 is returned, the port was neither created nor opened.
- The name of the application which uses the port must be unique on each call.
- Mask specifying which channels shall be used with this port.
- Mask specifying the channels for which the ports wants additional
access for initialisation (e.g. to set the bit timing). Only
one port can have init access to a channel.
- Pointer to a variable where the mask is returned for the channel
for which init access is granted.
- Size of the port’s receive queue allocated by the driver. Specifies how many events can be stored in the queue. The value
should be a power of 2. If not, the value is rounded up to the
next power of 2. (max. queue size is 32k)
Example:
Das Problem ist gPortHandle. Wie in der Beschreibung steht soll das ein Pointer sein. Aber wenn ich das Richtig verstehe ist das irgendein Pointer oder soll auf die Header Datei zugegriffen werden? Muss ich die einbinden? Soll ich die Header Datei auch posten?// select CANcardX channel 1
gChannelMask = ncdGetChannelMask(HWTYPE_CANCARDX,-1,0);
if(!gChannelMask) return VERR_HW_NOT_PRESENT;
// try to get init access to all channels
gInitMask = gChannelMask;
vErr = ncdOpenPort(&gPortHandle,„CANDEMO„,gChannelMask,gInitMask,
&gPermissionMask,1024);
Glaub was Pointer angeht ich hab aber schon alles Versucht.
Aber am heufigsten kommt:
WindowsError: exception: access violation writing 0x00000000
oder
TypeError: int expected instead of LP_c_long instance
Puhh. Glaub das ist jetzt mal nicht so einfach. Hoffe mir kann jemand Helfen. Wie würdet ihr das mit der Anleitung machen? Danke!