Difference between revisions of "LeapFrog Pollux Platform: DFTPdevice"
Line 1: | Line 1: | ||
Work in progress, just jotting down notes currently. | Work in progress, just jotting down notes currently. | ||
− | DFTPdevice is | + | DFTPdevice is a custom server LeapFrog includes with the [[Leapster_Explorer|Explorer]] and [[LeapPad_Explorer | LeapPad]]. This is the main interface between LFConnect, and these devices. DFTPdevice seems loosely based on an FTP server, while including customized features for the purposes of updating the firmware, and a general maintenance. |
+ | |||
== DFTP Device == | == DFTP Device == | ||
− | + | DFTPDevice is included in both LeapPad and Explorer versions of Surgeon.cbf and their respective firmwares. Surgeon's come with version 1.12, although there seems to be a slight difference in the two, as Explorer Surgeon will reboot if you destroy the sockets connected to it, LeapPad's will reset the DFTPDevice and got back to broadcasting its IP address. Explorer firmware contains version 1.18. | |
+ | TODO: Get LeapPad's version number | ||
− | |||
− | |||
− | |||
− | When device starts up port 5000 is open, once you make a connection, you need to send the ETH command. | + | Making a Connection. |
− | + | ||
+ | When the device starts up port 5000 is open, once you make a socket connection, you then need to send the ETH command. The device then opens up a socket to port 5001, make your second connection, and you can then start communicating with. | ||
5000 is the port you send commands to. | 5000 is the port you send commands to. | ||
Line 16: | Line 16: | ||
5001 is the port you read the responses from. | 5001 is the port you read the responses from. | ||
− | == | + | == Response Codes == |
+ | === Success === | ||
+ | The success code is sent for most commands to signify everything went okay. Will not be sent for data transfers, except on the 101 EOF packet. | ||
+ | |||
+ | '''200 OK'''' | ||
+ | |||
+ | === Data Transfer === | ||
+ | File transfer ACK. This is returned when the device is receiving data from an upload, it also needs to be send when downloading from it. The number seems to be the size of the last amount of data read. | ||
+ | |||
+ | '''100''' ACK <num> | ||
+ | |||
+ | EOF is the marker to signify all data has been sent, and to stop expecting it. When receiving data you need to check for this packet, and when uploading data you need to send it when finished. | ||
+ | |||
+ | '''101''' EOF | ||
+ | |||
+ | === Errors === | ||
+ | Server errors generate a response back that start with 5xx and then the error text. | ||
+ | |||
+ | '''500''' Command not found | ||
+ | |||
+ | '''501''' | ||
+ | |||
+ | '''502''' | ||
+ | |||
+ | '''503''' | ||
+ | |||
+ | '''550''' | ||
+ | |||
+ | == Command List == | ||
The command list is fairly undocumented, there is a few listed in the sources, but most will be discovered by other means, like using Wireshark. This is the list so far. | The command list is fairly undocumented, there is a few listed in the sources, but most will be discovered by other means, like using Wireshark. This is the list so far. | ||
Line 22: | Line 50: | ||
socket.send('LIST /path/to\x00') | socket.send('LIST /path/to\x00') | ||
− | In OpenLFConnect there is a special command send. It allows you to send any command you like, the 0x00 is appended for you, otherwise its all raw read/write. Obviously STOR | + | In OpenLFConnect there is a special command send. It allows you to send any command you like, the 0x00 is appended for you, otherwise its all raw read/write. Obviously STOR, RETR, RUN won't work with it, but the rest you can play around with. |
remote>send LIST /path/to | remote>send LIST /path/to | ||
Some commands are Surgeon only. | Some commands are Surgeon only. | ||
− | + | === Surgeon Only === | |
+ | |||
'''DFTP Version 1.12''' | '''DFTP Version 1.12''' | ||
+ | |||
'''GETS MFG_LOCALE''' | '''GETS MFG_LOCALE''' | ||
+ | |||
Returns: | Returns: | ||
MFG_LOCALE="" | MFG_LOCALE="" | ||
+ | |||
'''SETS MOUNTPATIENT=2 or 0''' | '''SETS MOUNTPATIENT=2 or 0''' | ||
+ | |||
Returns: | Returns: | ||
Line 44: | Line 77: | ||
'''GETS METAINFS''' | '''GETS METAINFS''' | ||
+ | |||
Returns: | Returns: | ||
Line 49: | Line 83: | ||
+ | === Universal === | ||
− | ''' | + | '''ETH <host ip> 1383''' |
− | + | Action: Has to do with establishing a connection. | |
− | + | Must be sent before opening the second port. | |
− | |||
'''LIST /path/to''' | '''LIST /path/to''' | ||
+ | |||
Returns: | Returns: | ||
− | <directory path> list 200 OK | + | <directory path> list |
+ | |||
+ | 200 OK | ||
'''STAT /path/to''' | '''STAT /path/to''' | ||
+ | |||
Returns: | Returns: | ||
Line 75: | Line 113: | ||
'''INFO''' | '''INFO''' | ||
+ | |||
Returns: | Returns: | ||
Line 85: | Line 124: | ||
'''GETS BATTERYLEVEL''' | '''GETS BATTERYLEVEL''' | ||
+ | |||
Returns: | Returns: | ||
Line 90: | Line 130: | ||
200 OK | 200 OK | ||
+ | |||
+ | Note: number/1000=volts | ||
'''GETS BATTERYSTATUS''' | '''GETS BATTERYSTATUS''' | ||
+ | |||
Returns: | Returns: | ||
Line 101: | Line 144: | ||
'''STOR /path/to''' | '''STOR /path/to''' | ||
+ | |||
Action: Initiate file upload. | Action: Initiate file upload. | ||
+ | |||
Next: Send file data till EOF then send 101 EOF. | Next: Send file data till EOF then send 101 EOF. | ||
+ | |||
Device responds with a lot of 100 ACK: <number> (Seems to be last amount of len(data) received.) | Device responds with a lot of 100 ACK: <number> (Seems to be last amount of len(data) received.) | ||
'''101 EOF''' | '''101 EOF''' | ||
+ | |||
Returns: | Returns: | ||
Line 112: | Line 159: | ||
Action: Ends STOR data transfer | Action: Ends STOR data transfer | ||
− | Notes:Must flush | + | Notes:Must flush receive buffer first |
Line 125: | Line 172: | ||
'''RM /path/to''' | '''RM /path/to''' | ||
+ | |||
Returns: | Returns: | ||
Line 133: | Line 181: | ||
'''RMD <path>''' | '''RMD <path>''' | ||
+ | |||
Returns: | Returns: | ||
Line 141: | Line 190: | ||
'''IPKG''' | '''IPKG''' | ||
+ | |||
Action:? | Action:? | ||
Line 146: | Line 196: | ||
− | '''SIZE /path/to''' Returns: | + | '''SIZE /path/to''' |
+ | |||
+ | Returns: | ||
a number, that doesn't seem to make sense | a number, that doesn't seem to make sense | ||
Line 152: | Line 204: | ||
'''SETS DATETIME=20120126083030''' | '''SETS DATETIME=20120126083030''' | ||
+ | |||
Returns: | Returns: | ||
Line 161: | Line 214: | ||
'''GETS DATETIME''' | '''GETS DATETIME''' | ||
+ | |||
Returns: | Returns: | ||
Line 167: | Line 221: | ||
'''GETS TOTALSPACE''' | '''GETS TOTALSPACE''' | ||
+ | |||
Returns: | Returns: | ||
Line 175: | Line 230: | ||
'''GETS FREESPACE''' | '''GETS FREESPACE''' | ||
+ | |||
Returns: | Returns: | ||
Line 180: | Line 236: | ||
'''GETS SERIAL''' | '''GETS SERIAL''' | ||
+ | |||
Returns: | Returns: | ||
SERIAL="XXXXXXXXXXXXXXXXXXXXX" | SERIAL="XXXXXXXXXXXXXXXXXXXXX" | ||
− | + | Note: This is the serial number of the device. | |
'''RUN''' | '''RUN''' | ||
Line 192: | Line 249: | ||
Next: Send data then 101 EOF | Next: Send data then 101 EOF | ||
− | Note: Make sure to remove any \r line ends will cause an error | + | Note: Make sure to remove any \r line ends as it will cause an error. |
+ | |||
+ | Example: | ||
+ | #!/bin/sh | ||
+ | /etc/init.d/telnet start | ||
+ | |||
+ | Would start the telnet client. | ||
Line 202: | Line 265: | ||
200 OK | 200 OK | ||
− | Note: | + | Note: If script is still running returns 1 |
− | === | + | === Combination Commands === |
'''Disconnect sequence''' | '''Disconnect sequence''' | ||
Line 211: | Line 274: | ||
DCON | DCON | ||
− | |||
Revision as of 09:32, 3 February 2012
Work in progress, just jotting down notes currently.
DFTPdevice is a custom server LeapFrog includes with the Explorer and LeapPad. This is the main interface between LFConnect, and these devices. DFTPdevice seems loosely based on an FTP server, while including customized features for the purposes of updating the firmware, and a general maintenance.
Contents
DFTP Device
DFTPDevice is included in both LeapPad and Explorer versions of Surgeon.cbf and their respective firmwares. Surgeon's come with version 1.12, although there seems to be a slight difference in the two, as Explorer Surgeon will reboot if you destroy the sockets connected to it, LeapPad's will reset the DFTPDevice and got back to broadcasting its IP address. Explorer firmware contains version 1.18. TODO: Get LeapPad's version number
Making a Connection.
When the device starts up port 5000 is open, once you make a socket connection, you then need to send the ETH command. The device then opens up a socket to port 5001, make your second connection, and you can then start communicating with.
5000 is the port you send commands to.
5001 is the port you read the responses from.
Response Codes
Success
The success code is sent for most commands to signify everything went okay. Will not be sent for data transfers, except on the 101 EOF packet.
200 OK'
Data Transfer
File transfer ACK. This is returned when the device is receiving data from an upload, it also needs to be send when downloading from it. The number seems to be the size of the last amount of data read.
100 ACK <num>
EOF is the marker to signify all data has been sent, and to stop expecting it. When receiving data you need to check for this packet, and when uploading data you need to send it when finished.
101 EOF
Errors
Server errors generate a response back that start with 5xx and then the error text.
500 Command not found
501
502
503
550
Command List
The command list is fairly undocumented, there is a few listed in the sources, but most will be discovered by other means, like using Wireshark. This is the list so far.
All commands must have a trailing 0x00 attached. In python it would look something like.
socket.send('LIST /path/to\x00')
In OpenLFConnect there is a special command send. It allows you to send any command you like, the 0x00 is appended for you, otherwise its all raw read/write. Obviously STOR, RETR, RUN won't work with it, but the rest you can play around with.
remote>send LIST /path/to
Some commands are Surgeon only.
Surgeon Only
DFTP Version 1.12
GETS MFG_LOCALE
Returns:
MFG_LOCALE=""
SETS MOUNTPATIENT=2 or 0
Returns:
200 OK
Action: 2 mounts patient-rfs 0 ?
GETS METAINFS
Returns:
METAINFS=/tmp/metainfs
Universal
ETH <host ip> 1383
Action: Has to do with establishing a connection.
Must be sent before opening the second port.
LIST /path/to
Returns:
<directory path> list
200 OK
STAT /path/to
Returns:
D 00000000 755 root:root
200 OK
Notes: Seems to not always work as expected.
INFO
Returns:
PACKETSIZE=131072
VERSION=1.12
200 OK
GETS BATTERYLEVEL
Returns:
BATTERYLEVEL=<number>
200 OK
Note: number/1000=volts
GETS BATTERYSTATUS
Returns:
BATTERYSTATUS=1
200 OK
STOR /path/to
Action: Initiate file upload.
Next: Send file data till EOF then send 101 EOF.
Device responds with a lot of 100 ACK: <number> (Seems to be last amount of len(data) received.)
101 EOF
Returns:
200 OK
Action: Ends STOR data transfer
Notes:Must flush receive buffer first
RETR /path/to
Action: Downloads file.
Next: Read socket buffer for data and send back 100 ACK: <number> (Seems to be last amount of len(data) received.)
Ends: When 101 EOF is received.
RM /path/to
Returns:
200 OK
Action: Removes file
RMD <path>
Returns:
200 OK
Action:Removes directory
IPKG
Action:?
Notes:Found listed in source code, does something with firmware.
SIZE /path/to
Returns:
a number, that doesn't seem to make sense
SETS DATETIME=20120126083030
Returns:
200 OK
Action: Sets time.
GETS DATETIME
Returns:
DATETIME=20120126083014 200 OK
GETS TOTALSPACE
Returns:
TOTALSPACE=397307904
200 OK
GETS FREESPACE
Returns:
FREESPACE=265678848
GETS SERIAL
Returns:
SERIAL="XXXXXXXXXXXXXXXXXXXXX"
Note: This is the serial number of the device.
RUN
Action: Runs shell script
Next: Send data then 101 EOF
Note: Make sure to remove any \r line ends as it will cause an error.
Example:
#!/bin/sh /etc/init.d/telnet start
Would start the telnet client.
GETS SCRIPT_RUNNING
Returns:
SCRIPT_RUNNING=0
200 OK
Note: If script is still running returns 1
Combination Commands
Disconnect sequence
NOOP
DCON
Reboot after update or in general
RSET
NOOP
DCON
Reboot to usb mode
UPD8
NOOP
DCON