Giter Club home page Giter Club logo

rbtemper's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

rbtemper's Issues

libusb compatibility

Hi,

What version of libusb did you use?

I am wondering because you include a header file called usb.h.
The normal libusb header file is called libusb.h.

And you are using type names and function names that are not defined by the official libusb header file:
http://libusb.sourceforge.net/api-1.0/libusb_8h_source.html

Thus I am not able to compile the ruby extension.

Best Regards
Markus

Random memory crashes on Rasbian

I have a long running process that checks the temp regularly. After several hundred checks I am getting malloc and/or free memory corruption errors and my whole ruby process is dumping. I've isolated it to this library... any ideas?

Driver not working with negative temps

I used some example code from another temper project to deal with negatives. This has been tested for my system only but seems to work.

static int interrupt_read_temperatura(usb_dev_handle *dev, float *tempC) {

    int r,i, temperature;
    char answer[reqIntLen];
    bzero(answer, reqIntLen);

    r = usb_interrupt_read(dev, 0x82, answer, reqIntLen, timeout);
    if( r != reqIntLen )
    {
        if(debug){
            printf("USB interrupt read");
        }
        return -1;
    }


    if(debug) {
        for (i=0;i<reqIntLen; i++) printf("%02x ",answer[i]  & 0xFF);

        printf("\n");
    }

    temperature = (answer[3] & 0xFF) + (answer[2] << 8);

    /* msb means the temperature is negative -- less than 0 Celsius -- and in 2'complement form.
    * We can't be sure that the host uses 2's complement to store negative numbers
    * so if the temperature is negative, we 'manually' get its magnitude
    * by explicity getting it's 2's complement and then we return the negative of that.
    */

        if ((answer[2] & 0x80)!=0) {
        /* return the negative of magnitude of the temperature */
            temperature = -((temperature ^ 0xffff)+1);
        }
    // end of the updates made for netgative temps
    *tempC = temperature * (125.0 / 32000.0);
    return 0;
  }

static int get_temperature(usb_dev_handle *dev, float *tempC){
    char buf[256];
    int ret, i, temperature;

    control_transfer(dev, uCmd1 );
    control_transfer(dev, uCmd4 );
    for(i = 0; i < 7; i++) {
        control_transfer(dev, uCmd0 );
    }
    control_transfer(dev, uCmd2 );
    ret = get_data(dev, buf, 256);
    if(ret < 2) {
        return -1;
    }

    temperature = (buf[1] & 0xFF) + (buf[0] << 8);


    /* msb means the temperature is negative -- less than 0 Celsius -- and in 2'complement form.
    * We can't be sure that the host uses 2's complement to store negative numbers
    * so if the temperature is negative, we 'manually' get its magnitude
    * by explicity getting it's 2's complement and then we return the negative of that.
    */

        if ((buf[0] & 0x80)!=0) {
        /* return the negative of magnitude of the temperature */
            temperature = -((temperature ^ 0xffff)+1);
        }

    // end up the updates made.

    *tempC = temperature * (125.0 / 32000.0);
    return 0;
 } 

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.