def create(self, typ, data, callback=None):
     #print "create", typ
     request = CreateFile(len(data), 0x80, [typ, 0x00, 0x00], [0x00, 0xff, 0xff])
     self._send_commandpipe(request.get())
     result = self._get_commandpipe()
     #result._debug()
     
     if result.get_response() != Response.Response.OK:
         raise AntFSCreateFileException("Could not create file",
                 result.get_response())
     
     #print "create result", result, result.get_index(), result.get_data_type(), result.get_identifier()
     #d = self.download_directory()
     
     self.upload(result.get_index(), data, callback)
     return result.get_index()
def main():

    # Test create file
    data    = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]
    request = CreateFile(len(data), 0x80, [0x04, 0x00, 0x00], [0x00, 0xff, 0xff])
    print request
    print request.get()
    
    # Test create file response
    response_data = array.array('B', [2, 0, 0, 0, 4, 0, 0, 0, 128, 4, 123, 0, 103, 0, 0, 0])
    response = parse(response_data)
    assert response.get_request_id() == 0x04
    assert response.get_response()   == 0x00
    assert response.get_data_type()  == 0x80 #FIT
    assert response.get_identifier() == array.array('B', [4, 123, 0])
    assert response.get_index()      == 103
    def create(self, typ, data, callback=None):
        #print "create", typ
        request = CreateFile(len(data), 0x80, [typ, 0x00, 0x00],
                             [0x00, 0xff, 0xff])
        self._send_commandpipe(request.get())
        result = self._get_commandpipe()
        #result._debug()

        if result.get_response() != Response.Response.OK:
            raise AntFSCreateFileException("Could not create file",
                                           result.get_response())

        #print "create result", result, result.get_index(), result.get_data_type(), result.get_identifier()
        #d = self.download_directory()

        self.upload(result.get_index(), data, callback)
        return result.get_index()
def main():

    # Test create file
    data = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]
    request = CreateFile(len(data), 0x80, [0x04, 0x00, 0x00],
                         [0x00, 0xff, 0xff])
    print request
    print request.get()

    # Test create file response
    response_data = array.array(
        'B', [2, 0, 0, 0, 4, 0, 0, 0, 128, 4, 123, 0, 103, 0, 0, 0])
    response = parse(response_data)
    assert response.get_request_id() == 0x04
    assert response.get_response() == 0x00
    assert response.get_data_type() == 0x80  #FIT
    assert response.get_identifier() == array.array('B', [4, 123, 0])
    assert response.get_index() == 103
Пример #5
0
    def create(self, typ, data, callback=None):
        # print "create", typ
        request = CreateFile(len(data), 0x80, [typ, 0x00, 0x00], [0x00, 0xFF, 0xFF])
        self._send_commandpipe(request.get())
        result = self._get_commandpipe()
        # result._debug()

        if result.get_response() != Response.Response.OK:
            raise AntFSCreateFileException("Could not create file", result.get_response())

        # print "create result", result, result.get_index(), result.get_data_type(), result.get_identifier()
        # d = self.download_directory()

        # Inform the application that the upload request was successfully created
        if callback is not None:
            callback(0)

        self.upload(result.get_index(), data, callback)
        return result.get_index()
Пример #6
0
    def create(self, typ, data, callback=None):
        # print "create", typ
        request = CreateFile(len(data), 0x80, [typ, 0x00, 0x00],
                             [0x00, 0xFF, 0xFF])
        self._send_commandpipe(request.get())
        result = self._get_commandpipe()
        # result._debug()

        if result.get_response() != Response.Response.OK:
            raise AntFSCreateFileException("Could not create file",
                                           result.get_response())

        # print "create result", result, result.get_index(), result.get_data_type(), result.get_identifier()
        # d = self.download_directory()

        # Inform the application that the upload request was successfully created
        if callback is not None:
            callback(0)

        self.upload(result.get_index(), data, callback)
        return result.get_index()
Пример #7
0
    def runTest(self):
        # Test create file
        data = [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09]
        request = CreateFile(len(data), 0x80, [0x04, 0x00, 0x00],
                             [0x00, 0xff, 0xff])

        # Test create file response
        response_data = array.array(
            'B', [2, 0, 0, 0, 4, 0, 0, 0, 128, 4, 123, 0, 103, 0, 0, 0])
        response = parse(response_data)
        self.assertEqual(response.get_request_id(), 0x04)
        self.assertEqual(response.get_response(), 0x00)
        self.assertEqual(response.get_data_type(), 0x80)  # FIT
        self.assertEqual(response.get_identifier(),
                         array.array('B', [4, 123, 0]))
        self.assertEqual(response.get_index(), 103)
Пример #8
0
    def runTest(self):
        # Test create file
        data = b"\x01\x02\x03\x04\x05\x06\x07\x08\x09"
        request = CreateFile(len(data), 0x80, [0x04, 0x00, 0x00],
                             [0x00, 0xFF, 0xFF])

        # Test create file response
        response_data = array.array(
            "B",
            b"\x02\x00\x00\x00\x04\x00\x00\x00\x80\x04\x7b\x00\x67\x00\x00\x00"
        )
        response = parse(response_data)
        self.assertEqual(response.get_request_id(), 0x04)
        self.assertEqual(response.get_response(), 0x00)
        self.assertEqual(response.get_data_type(), 0x80)  # FIT
        self.assertEqual(response.get_identifier(),
                         array.array("B", b"\x04\x7b\x00"))
        self.assertEqual(response.get_index(), 103)