GithubHelp home page GithubHelp logo

marceluphd / cctalk-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitcoding/cctalk

0.0 0.0 0.0 14 KB

c(+ c++ later) library to provide cctalk protocol

License: MIT License

CMake 1.61% C 98.39%

cctalk-1's Introduction

        #include <cctalk/cctalk.h> 
        
        
        char *device = NULL;
        
        device = strdup("/dev/ttyUSB0");
        struct cctalk_host *host;
        
        if (NULL == (host = new_cctalk_host(device,200,CCTALK_CRC_SIMPLE,hostid)))
            error(1, errno, "failed to open device %s", device);
        
        struct cctalk_device* device = new_cctalk_device(host,1);
        struct cctalk_coinacceptor* acceptor = new_cctalk_coinacceptor(device);
        
        
        for(uint8_t i = 0; i< acceptor->coincount;i++){
            COIN_ID* coin = &acceptor->coins[i];
            printf(" %c%c %i  %c\n", coin->country[0], coin->country[1],atoi((const char*)&coin->value),coin->letter);   
        }
        
        acceptor->device->master.master = 1;
        acceptor->device->inhibit.mask1.d = 255;
        acceptor->device->inhibit.mask2.d = 255;
        
        cctalk_device_inhibit_status(acceptor->device,
                    &acceptor->device->master,
                    &acceptor->device->inhibit);
        
        
        uint8_t lastevent = 0;
        write_cctalk_device(device,CCTALK_METHOD_READ_BUFFERED_CREDIT_OR_ERROR_CODES,NULL,0);
        struct cctalk_message* nmsg = read_cctalk_device(device);
        
        if(nmsg){
            R_READ_BUFFERED_CREDIT_OR_ERROR_CODES code;
            memcpy(&code, nmsg->data, nmsg->length);
            printf("%i\n",code.eventcounter);
            lastevent=code.eventcounter;
        }

cctalk-1's People

Contributors

bitcoding avatar

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.