[PLUG] temperpi modifications...

Michael Christopher Robinson michael at robinson-west.com
Tue Mar 28 23:19:03 UTC 2017


A colleague and I are trying to improve upon a project for the
Raspberry Pi by Rui Barbosa Martins and others.  The project 
before modification allows the use of one TEMPer2 USB 
thermometer.  I want to use six sensors.

https://github.com/ruibm/temperpi

The following is a snippet from comm.c:

...
// Read from temperature sensor Temper into buffer and return status.
int TemperInterruptRead(Temper* t, unsigned char *buf, unsigned int
len)
{
        printf("%s\n","TemperInterruptRead entered...");

        int ret;

        if (t->debug)
        {
                printf("interrupt read\n");
        }

printf("-----------------------------------------------------------\n"
        printf("%s%d\n","Size of buf:",sizeof(buf));
        printf("%s%d\n","Size of temper:",sizeof(t));
        printf("%s%d\n","Size of len:",len);
printf("-----------------------------------------------------------\n"

        printf("%s\n","About to call usb_interrupt_read");

ret = usb_interrupt_read(t->handle, 0x82, (char*)buf, len, t->timeout);
        if(t->debug)
        {
                printf("receiving %d bytes\n",ret);
                for(int i = 0; i < ret; ++i)
                {
                        printf("%02x ", buf[i]);
                        if ((i+1)%8 == 0) printf("\n");
                }
                printf("\n");
        }

        return ret;
}		
...

Anthony and I have traced the crash to this line:

ret = usb_interrupt_read(t->handle, 0x82, (char*)buf, len, t->timeout);

What is an unsigned char and why would one not use a standard char
instead?  The 0x82 argument, what is that and how is it used by
usb_interrupt_read?

pi at raspberrypi:~/temperpi-3-21-2017/client/TEMPer2 $ 
./temper temper.sqlite3 0
...
*** buffer overflow detected ***: ./temper terminated
Aborted

Do Anthony and I need to go into libusb itself and find
usb_interrupt_read to fix this?
-------------- next part --------------
Temper original work by Robert Kavaler (c) 2009 (relavak.com)
All rights reserved.

Modified by Sylvain Leroux (c) 2012 (sylvain at chicoree.fr)


Temper driver for linux. This program can be compiled either as a library
or as a standalone program (-DUNIT_TEST). The driver will work with some
TEMPer usb devices from RDing (www.PCsensor.com).

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL Robert kavaler BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.




More information about the PLUG mailing list