Code Monkey home page Code Monkey logo

python3-bindings-2.0-dc01l's Introduction

bitlib

bitlib -- bitlib Python3 Library API Bindings V3.0

Install

  • clone this repository using

    $ git clone [email protected]:codenio/python3-bindings-2.0-DC01L.git
  • install bitlib library from ./src directory for your Operating System (identified by file suffix):

    # cd into src/ directory
    $ cd src/
    
    # install the bitscope-library_2.0 debian package for Linux 64 bit os  
    $ sudo apt-get install ./bitscope-library_2.0.FE26B_amd64.deb
    
    # install bitlib using the python-binding script 
    $ sudo python3 setup-bitlib.py install
    
    # in case of errors.. try
    $ sudo BASECFLAGS="" OPT="" CFLAGS="-O3" python3 setup-bitlib.py install
    
  • connect your bitscope micro to your pc and test the functionality using the example file at test-bitlib.py

    $ python3 test-bitlib.py 
        Starting: Attempting to open one device...
        Library: 2.0 FE26B (Python DC01L)
            Link: USB:/dev/ttyUSB0
        BitScope: BS000501 (*****)
        Channels: 10 (2 analog + 8 logic)
        Modes: FAST DUAL MIXED LOGIC STREAM
        Capture: 12288 @ 40000000Hz = 0.000307s (LOGIC)
        Offset: +2.917V to -6.217V
            POD:  9.20V  5.20V  3.50V  1.10V
        Data(5): 1.689062, 1.689062, 1.689062, 1.689062, 1.689062
        Finished: Library closed, resources released.

python3-bindings-2.0-dc01l's People

Contributors

codenio avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

filsgrp

python3-bindings-2.0-dc01l's Issues

Can't build whl on Windows

bitscope-library_2.0.FE26B_i386.zip installed in E:\BitScope\Library (includes bitlib.h BitLib.lib)

modified setup-bitlib.py:

from setuptools import setup, Extension

module = Extension(
    'bitlib',
    libraries=['BitLib'],
    include_dirs=[r'E:\BitScope\Library'],
    library_dirs=[r'E:\BitScope\Library'],
    sources=['bitlibmodule.c']
)

setup(
    name="bitlib",
    version="2.0",
    maintainer="codenio",
    maintainer_email="[email protected]",
    description="BitScope Library Python3 Extension module",
    ext_modules=[module]
)

modified bitlibmodule.c on line78:

static PyObject * bitlib_BL_Acquire ( PyObject * self, PyObject * args ) {
	PyObject * L = NULL; int N = 0; bool Alternate = 0;
	if ( ! PyArg_ParseTuple(args, "|iO", &N, &L) )
		return NULL;
	if ( N <= 0 )
		N = BL_Size(BL_ASK);
	if ( N <= 0 ) {
		PyErr_SetString(PyExc_TypeError, "Acquisition size is unknown."); 
		return NULL;
	}
	if ( L && ! PyList_Check( L ) ) {
		PyErr_SetString(PyExc_TypeError, "Second argument should be a list."); 
		return NULL;
	} else { int i;
        double *D = malloc(N * sizeof(double));
        if (D == NULL) {
            PyErr_SetString(PyExc_MemoryError, "Unable to allocate memory.");
            return NULL;
        }
		N = BL_Acquire( N, D );
		if ( N > 0 ) {
			if ( ! L ) {
				L = PyList_New(N);
				Alternate = 1;
			}
			for ( i = 0; i < N; i++ ) 
				PyList_SetItem( L, i, Py_BuildValue("d", D[i]) );
			if ( Alternate ) 
				return L;
		}
		return Py_BuildValue("l", (long) N );
	}
}

run script python setup-bitlib.py install

came out:

running install
running bdist_egg
running egg_info
writing bitlib.egg-info\PKG-INFO
writing dependency_links to bitlib.egg-info\dependency_links.txt
writing top-level names to bitlib.egg-info\top_level.txt
reading manifest file 'bitlib.egg-info\SOURCES.txt'
writing manifest file 'bitlib.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_ext
building 'bitlib' extension
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -IE:\BitScope\Library -IE:\Anaconda\Anaconda3\envs\ml\include -IE:\Anaconda\Anaconda3\envs\ml\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\cppwinrt" /Tcbitlibmodule.c /Fobuild\temp.win-amd64-3.8\Release\bitlibmodule.obj
bitlibmodule.c
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\link.exe /nologo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:E:\BitScope\Library /LIBPATH:E:\Anaconda\Anaconda3\envs\ml\libs /LIBPATH:E:\Anaconda\Anaconda3\envs\ml\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\lib\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\lib\um\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\lib\10.0.16299.0\um\x64" BitLib.lib /EXPORT:PyInit_bitlib build\temp.win-amd64-3.8\Release\bitlibmodule.obj /OUT:build\lib.win-amd64-3.8\bitlib.cp38-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.8\Release\bitlib.cp38-win_amd64.lib
  正在创建库 build\temp.win-amd64-3.8\Release\bitlib.cp38-win_amd64.lib 和对象 build\temp.win-amd64-3.8\Release\bitlib.cp38-win_amd64.exp
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Mode
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Delay
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Select
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Send
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Receive
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_State
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Acquire
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Count
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Offset
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Version
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Close
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Trigger
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Time
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Intro
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Coupling
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Log
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Initialize
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Rate
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Trace
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Range
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Enable
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Halt
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Size
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_ID
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Index
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Name
bitlibmodule.obj : error LNK2001: 无法解析的外部符号 BL_Open
build\lib.win-amd64-3.8\bitlib.cp38-win_amd64.pyd : fatal error LNK1120: 27 个无法解析的外部命令
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.29.30133\\bin\\HostX86\\x64\\link.exe' failed with exit status 1120

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.