Changeset 192e299 in thomson for elec/CrO2/software/device.cpp


Ignore:
Timestamp:
Feb 3, 2012, 7:37:06 PM (12 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
c2a9854
Parents:
f9263dd
Message:

Cleanup.

git-svn-id: svn://localhost/thomson@15 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • elec/CrO2/software/device.cpp

    rf9263dd r192e299  
    88
    99#include "device.h"
     10#include "k5.h"
    1011
    1112bool Device::initOnce = false;
     
    141142}
    142143
     144
     145void Device::write(K5& file)
     146{
     147        for (int k = 0; k < file.getBlockCount(); k++)
     148        {
     149                // wait for motor on
     150                while (getStatus() & 8)
     151                        Sleep(1000);
     152
     153                K5::Block block = file.getBlock(k);
     154
     155                int nBytes = write(block.data, block.length - 1, block.type);
     156                        // TODO error handling
     157
     158                // TODO wait for correct time (read status from usb OR compute from size+type)
     159                Sleep(1400);
     160        }
     161}
     162
    143163uint8_t Device::getStatus()
    144164{
    145165        uint8_t status;
    146166        usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,
    147                 PSCMD_STATUS, 0,0, (char*)&status, 1, 5000);
     167                        PSCMD_STATUS, 0,0, (char*)&status, 1, 5000);
    148168                // TODO handle errors (return value)
    149169        return status;
Note: See TracChangeset for help on using the changeset viewer.