• 大小: 39.83MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-02
  • 语言: 其他
  • 标签: canopen  伺服  

资源简介

kvaser的驱动软件,附带简要使用说明,应用于伺服驱动器canopen通信

资源截图

代码片段和文件信息

/*
**                        Copyright 19951996 by KVASER AB
**            P.O Box 4076 S-51104 KINNA SWEDEN. Tel. +46 320 15287
**
** This software is furnished under a license and may be used and copied
** only in accordance with the terms of such license.
**
*/
/*
** This module contains the entry points to the library.
** The code typically performs tasks like parameter checking and
** conversion and then calls the appropriate hardware-dependent
** routines.  Also all readings from the ring buffer take place here.
**
*/
#include 
#include 
#include             // _enable _disable
#include 

#include 
#include 
// #include 
#include “global.h“
#include “irq.h“
#include “timer.h“
#include “version.h“
#include “misc.h“

#include “libpccan.h“
#include “libcanc.h“

// For lapCAN - not yet working.
// #include “hwLapCAN.h“
// #include “lpaction.h“ // qqq lapcan!

#define VALIDATE(h) \
    if (!Initialized) return canERR_NOTINITIALIZED; \
    if (!IsHandleValidAndOpen(h)) return canERR_INVHANDLE

/*
** Forward declarations.
*/
#ifndef _WINDOWS
PRIVATE int LibMain(void);
#endif

/* These following two routines should be moved to util.c someday. */

/* The time values are read using GetMsTimer() which returns the timer value in ms.
** When it reaches 0x100000000/1193 = 3600140.23 ms or about one hour
** ‘ReadTimer()/TIMERFREQ‘ will wrap causing troubles when it is used in timeouts
** etc (where two times are simply subtracted). In theese cases one should use
** the TimeDiff-function instead which works for time differences less than one
** hour
*/
#define TIMERPERIOD 3600140L
/*
** Calculates (t2-t1) mod TIMERPERIOD
*/
PRIVATE DWORD TimeDiff(DWORD t2 DWORD t1)
{
    // The times are DWORDs/1193 so they will fit in a signed long.
    long d = (long)t2 - (long)t1;
    if (d < 0)
        d += TIMERPERIOD;
    return d;
}

/* Timeout handling.
** Call it first with argument 0 to initialize it then call it with the
** timeout and if timeout occur 1 is returned.
**
** To avoid a bug in the timer routines two ‘timeout/2‘ has to occur before
** it is considered valid. This means that at worst only half of the timeout
** value will be used.
*/
PRIVATE int Timeout(DWORD timeout)
{
    static DWORD t0;
    DWORD t1;
    static int toCount;

    if (timeout == 0) {
        t0 = GETTIMER();
        toCount = 0;
    } else {
        t1 = GETTIMER();
        if (TimeDiff(t1 t0) > timeout/2) {
            if (toCount++)
                return 1;
            else
                t0 = GETTIMER(); // Try again
        }
    }
    return 0;
}

//
// canInitializeLibrary - an initialization entry point with
// a more sensible name.
//
void CANLIBAPI canInitializeLibrary( void)
{
    (void)canLocateHardware();
}

/*
** canLocateHardware - initializes the data structures using the information

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-11-27 15:05  kvaser使用\
     文件       90920  2016-05-24 10:45  kvaser使用\CanKing.docx
     目录           0  2017-11-27 15:04  kvaser使用\Driver and CANlib\
     目录           0  2017-11-27 15:05  kvaser使用\Driver and CANlib\CANlib\
     目录           0  2017-11-27 15:04  kvaser使用\Driver and CANlib\CANlib\Bin\
     文件        1132  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\CplTasksFile.xml
     目录           0  2017-11-27 15:04  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\
     文件       86112  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\canlib32.dll
     文件       57451  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\canlib_install.dll
     文件       69729  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\j1587lib.dll
     文件      139361  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\kvaDbLib.dll
     文件      225373  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\kvalapw2.dll
     文件      122986  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\kvaser_vcndrvms.dll
     文件       69725  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\linlib.dll
     文件      102496  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\sing32.dll
     文件      122974  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\vcand32.dll
     文件      122978  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\Debug\vcndrvms.dll
     文件         905  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\IsaToPciRouting-Readme.txt
     文件         129  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\IsaToPciRoutingDisable.reg
     文件         129  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\IsaToPciRoutingEnable.reg
     文件       65536  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\KvEnumSrv.exe
     文件      584192  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\ListChannels.exe
     文件       70234  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\bb_help.chm
     文件      573440  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\bittime.exe
     文件       73728  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\canlib32.dll
     文件       69632  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\canlib32NET.dll
     文件       69632  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\canlibCLSNET.dll
     文件       49152  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\canlib_install.dll
     文件     1245696  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\conftool.exe
     文件      602296  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\conftool_help.chm
     文件       69632  2009-10-22 00:41  kvaser使用\Driver and CANlib\CANlib\Bin\filo_setparam_userdata.exe
............此处省略517个文件信息

评论

共有 条评论