PTP Service

Files CCore/inc/net/PTPExtra.h CCore/src/net/PTPExtra.cpp

PTP server may provide a variety of functions. Usually they are grouped in services. There is a standard way to encode a PTP service interaction.

The standard list of common types:


using ServiceIdType = uint32 ;

using FunctionIdType = uint32 ;

using LenType = uint32 ;

using BoolType = uint32 ;

using FlagType = uint32 ;

using ErrorIdType = uint32 ;

ServiceIdType identifies a service.

FunctionIdType specifies a function of a service.

LenType encodes the array data length.

BoolType encodes a boolean value.

FlagType encodes a set of flags.

ErrorIdType encodes a error code, null value means no error.

The list of basic error codes:


const ErrorIdType NoError    = 0 ;
const ErrorIdType BadInput   = 1 ;
const ErrorIdType NoFunction = 2 ;
const ErrorIdType Exhausted  = 3 ;
const ErrorIdType Unknown    = 4 ;

NoError — no error.

BadInput — the input data are invalid.

NoFunction — the function or service id is invalid.

Exhausted — server has not enough resources to serve the request.

Unknown — any error.

Two common derived types:


struct ServiceFunction
 {
  ServiceIdType service_id;
  FunctionIdType function_id;
 };
 
struct Result // if( error_id==NoError ) result follows
 {
  ServiceFunction serv_func;
  ErrorIdType error_id;
 }; 

Client info starts from the ServiceFunction header, followed by function arguments. The bigendian byte order is used to encode integral values.

Server info starts from the Result. serv_func field is a copy from the client info. If the error code is null, the result follows after.

If a client info has no proper header (i.g. it is too short), the server cancels transaction.

The file txt/cpp/PTPService.txt.cpp contains all of these definitions.

PTPExtra.h defines these entities withing namespace PTP.