2 // TFUSBControllerCommunicationBlock.h
5 // Created by Kalle Olavi Niemitalo on 2007-10-23, based on:
8 // Created by Nathan Oates on Sun Aug 01 2004.
9 // Copyright (c) 2004-7 Nathan Oates. All rights reserved.
10 // May also include parts of:
12 // Copyright (c) 2001 Kasima Tharnpipitchai <me@kasima.org>
14 // This source code is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU Public License as published
16 // by the Free Software Foundation; either version 2 of the License,
17 // or (at your option) any later version.
19 // This source code is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 // Please refer to the GNU Public License for more details.
24 // You should have received a copy of the GNU Public License along with
25 // this source code; if not, write to:
26 // Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
28 #import "TFUSBController.h"
30 #define USB_CmdNone 0x00000000
32 #define USB_Fail 0x00000001
33 #define USB_Success 0x00000002
34 #define USB_Cancel 0x00000003
36 #define USB_CmdReady 0x00000100
37 #define USB_CmdReset 0x00000101
38 #define USB_CmdTurbo 0x00000102
41 #define USB_CmdHddSize 0x00001000
42 #define USB_DataHddSize 0x00001001
44 #define USB_CmdHddDir 0x00001002
45 #define USB_DataHddDir 0x00001003
46 #define USB_DataHddDirEnd 0x00001004
48 #define USB_CmdHddDel 0x00001005
49 #define USB_CmdHddRename 0x00001006
50 #define USB_CmdHddCreateDir 0x00001007
52 #define USB_CmdHddFileSend 0x00001008
53 #define USB_DataHddFileStart 0x00001009
54 #define USB_DataHddFileData 0x0000100A
55 #define USB_DataHddFileEnd 0x0000100B
57 // -----------------------------------------------------------------------------
59 #define USB_OK 0x00000000
60 #define USB_Err_Crc 0x00000001
61 #define USB_Err_UnknownCmd 0x00000002
62 #define USB_Err_InvalidCmd 0x00000003
63 #define USB_Err_Unknown 0x00000004
64 #define USB_Err_Size 0x00000005
65 #define USB_Err_RunFail 0x00000006
66 #define USB_Err_Memory 0x00000007
68 // -----------------------------------------------------------------------------
70 #define USB_FileToDevice 0x00
71 #define USB_FileToHost 0x01
73 // -----------------------------------------------------------------------------
75 #define USB_FileTypeFolder 0x01
76 #define USB_FileTypeNormal 0x02
78 // -----------------------------------------------------------------------------
79 #define USB_FileTypeSize 114
80 #define USB_FileNameSize 95
82 @interface
TFUSBController (CommunicationBlock
)
84 // Framing of communication blocks
85 - (UInt16
) findCRC
:(const UInt8
*)p length
:(size_t)n
;
86 - (NSMutableData
*) swap
:(NSData
*)inData
;
87 - (NSData
*) prepareCommand
:(UInt32
)cmd withData
:(NSData
*)inData
;
88 - (UInt32
) checkCommunicationBlock
:(NSData
*)block
;
89 - (UInt32
) cmdFromCommunicationBlock
:(NSData
*)block
;
90 - (BOOL
) appendToData
:(NSMutableData
*)data fname
:(NSString
*)fname
;
91 - (BOOL
) appendToData
:(NSMutableData
*)data sizeAndFname
:(NSString
*)fname
;
93 // Preparing communication blocks for various commands
94 - (NSData
*) prepareFailWithECode
:(UInt32
)eCode
;
95 - (NSData
*) prepareSuccess
;
96 - (NSData
*) prepareCancel
;
97 - (NSData
*) prepareCmdHddDirWithPath
:(NSString
*)path
;
98 - (NSData
*) prepareCmdHddFileSendWithDirection
:(UInt8
)direction
99 fname
:(NSString
*)fname offset
:(UInt64
)offset
;
100 - (NSData
*) prepareDataHddFileEnd
;
101 - (NSData
*) prepareCmdTurboWithMode
:(SInt32
)mode
;
102 - (NSData
*) prepareCmdHddDelWithFname
:(NSString
*)fname
;
103 - (NSData
*) prepareCmdHddRenameFromFname
:(NSString
*)oldFname
104 toFname
:(NSString
*)newFname
;
105 - (NSData
*) prepareCmdHddCreateDirWithFname
:(NSString
*)fname
;
106 - (NSString
*) fnameForFile
:(NSString
*)file atPath
:(NSString
*)path
;