summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeddy <[email protected]>2013-08-22 20:47:32 +0800
committerTeddy <[email protected]>2013-08-22 20:47:32 +0800
commitd5fb5706c2da144fc912fdaaeef0aa2b32b0b3b4 (patch)
tree5a77291798f082cbb214251b81a1d963bfff2705
parent8d47f6890d31d1eac483249de99c846f59366c60 (diff)
more detailed type info in `ptp.rst`
-rw-r--r--server/client.py6
-rw-r--r--server/piztor_server.py6
-rw-r--r--server/ptp.rst54
3 files changed, 33 insertions, 33 deletions
diff --git a/server/client.py b/server/client.py
index b1a6d86..5b3fde6 100644
--- a/server/client.py
+++ b/server/client.py
@@ -12,10 +12,10 @@ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
#data += "\0"
#data += "world"
-#data = pack("!Bll", 1, 1234, 5678)
-#data += "hello, world!"
+data = pack("!BLL", 1, 1234, 5678)
+data += "hello, world!"
-data = pack("!Bldd", 2, 1234, 123.123, 12323.23222)
+#data = pack("!BLdd", 2, 1234, 123.123, 12323.23222)
print data
try:
diff --git a/server/piztor_server.py b/server/piztor_server.py
index 4845748..663d2fa 100644
--- a/server/piztor_server.py
+++ b/server/piztor_server.py
@@ -41,7 +41,7 @@ class UserManager(DataManager):
username = data[0:pos]
password = data[pos + 1:]
print (username, password)
- return struct.pack("!Bl", 0, 1234)
+ return struct.pack("!BL", 0, 1234)
class MesgManager(DataManager):
@@ -50,7 +50,7 @@ class MesgManager(DataManager):
try:
if len(data) < 8:
raise ReqInvalidError()
- sender_token, recv_id = struct.unpack("!ll", data[:8])
+ sender_token, recv_id = struct.unpack("!LL", data[:8])
msg = data[8:]
print (sender_token, recv_id, msg)
return struct.pack("!B", 1)
@@ -63,7 +63,7 @@ class LocationManager(DataManager):
try:
if len(data) < 8:
raise ReqInvalidError()
- sender_token, lat, lont = struct.unpack("!ldd", data)
+ sender_token, lat, lont = struct.unpack("!Ldd", data)
print (sender_token, lat, lont)
return struct.pack("!B", 2)
except struct.error:
diff --git a/server/ptp.rst b/server/ptp.rst
index 93f03ea..bf74d10 100644
--- a/server/ptp.rst
+++ b/server/ptp.rst
@@ -9,7 +9,7 @@ Piztor Transmission Protocol v0.1
+---1b---+-------?b--------+
| OPT ID | SPECIFIC DATA |
- +--------+-----------------+
+ +-uchar--+-----------------+
- Response
@@ -17,7 +17,7 @@ Piztor Transmission Protocol v0.1
+---1b---+------?b---------+
| OPT ID | SPECIFIC DATA |
- +--------+-----------------+
+ +-uchar--+-----------------+
- Authentication
@@ -25,17 +25,17 @@ Piztor Transmission Protocol v0.1
::
- +--1b--+-----?b------+-----?b-----+
- | 0x00 | USERNAME | PASSWORD |
- +------+-------------+------------+
+ +--1b---+-----?b------+-----?b-----+
+ | 0x00 | USERNAME | PASSWORD |
+ +-uchar-+-------------+------------+
- Response
::
- +--1b--+-----4b-----+
- | 0x00 | USER_TOKEN |
- +------+------------+
+ +--1b---+-----4b-----+
+ | 0x00 | USER_TOKEN |
+ +-uchar-+----uint----+
- Message Sending
@@ -43,17 +43,17 @@ Piztor Transmission Protocol v0.1
::
- +--1b--+------4b------+------4b-----+
- | 0x01 | SENDER_TOKEN | RECEIVER_ID |
- +------+--------------+-------------+
+ +--1b---+------4b------+------4b-----+
+ | 0x01 | SENDER_TOKEN | RECEIVER_ID |
+ +-uchar-+-----uint-----+----uint-----+
- Response
::
- +--1b--+----?b----+
- | 0x01 | RESERVED |
- +------+----------+
+ +--1b---+----?b----+
+ | 0x01 | RESERVED |
+ +-uchar-+----------+
- Location Update
@@ -61,17 +61,17 @@ Piztor Transmission Protocol v0.1
::
- +--1b--+------4b------+-----8b-----+------8b-----+
- | 0x02 | SENDER_TOKEN | LATITUDE | LONGITUDE |
- +------+--------------+------------+-------------+
+ +--1b---+------4b------+-----8b-----+------8b-----+
+ | 0x02 | SENDER_TOKEN | LATITUDE | LONGITUDE |
+ +-uchar-+-----uint-----+---double---+---double----+
- Response
::
- +--1b--+----?b----+
- | 0x02 | RESERVED |
- +------+----------+
+ +--1b---+----?b----+
+ | 0x02 | RESERVED |
+ +-uchar-+----------+
- Location Information
@@ -79,17 +79,17 @@ Piztor Transmission Protocol v0.1
::
- +--2b--+-----4b-------+------4b-----+
- | 0x03 | SENDER_TOKEN | GROUP_ID |
- +------+--------------+-------------+
+ +--1b---+-----4b-------+------4b-----+
+ | 0x03 | SENDER_TOKEN | GROUP_ID |
+ +-uchar-+----uint------+----uint-----+
- Response
::
- +--2b--+-----20b--------+-----+
- | 0x03 | LOCATION_ENTRY | ... |
- +------+----------------+-----+
+ +--1b---+-----20b--------+-----+
+ | 0x03 | LOCATION_ENTRY | ... |
+ +-uchar-+----------------+-----+
Location Entry:
@@ -97,5 +97,5 @@ Piztor Transmission Protocol v0.1
+---4b----+----8b----+-----8b----+
| USER_ID | LATITUDE | LONGITUDE |
- +---------+----------+-----------+
+ +--uint---+--double--+--double---+