plptools
Loading...
Searching...
No Matches
rpcs Class Referenceabstract

Remote procedure call services via PLP. More...

#include <rpcs.h>

Inheritance diagram for rpcs:
Collaboration diagram for rpcs:

Classes

struct  machineInfo_t
 This struct holds the data returned by rpcs::getMachineInfo. More...
 

Public Types

enum  machs {
  PSI_MACH_UNKNOWN = 0 , PSI_MACH_PC = 1 , PSI_MACH_MC = 2 , PSI_MACH_HC = 3 ,
  PSI_MACH_S3 = 4 , PSI_MACH_S3A = 5 , PSI_MACH_WORKABOUT = 6 , PSI_MACH_SIENA = 7 ,
  PSI_MACH_S3C = 8 , PSI_MACH_S5 = 32 , PSI_MACH_WINC = 33
}
 The known machine types. More...
 
enum  languages {
  PSI_LANG_TEST = 0 , PSI_LANG_en_GB = 1 , PSI_LANG_fr_FR = 2 , PSI_LANG_de_DE = 3 ,
  PSI_LANG_es_ES = 4 , PSI_LANG_it_IT = 5 , PSI_LANG_sv_SE = 6 , PSI_LANG_da_DK = 7 ,
  PSI_LANG_no_NO = 8 , PSI_LANG_fi_FI = 9 , PSI_LANG_en_US = 10 , PSI_LANG_fr_CH = 11 ,
  PSI_LANG_de_CH = 12 , PSI_LANG_pt_PT = 13 , PSI_LANG_tr_TR = 14 , PSI_LANG_is_IS = 15 ,
  PSI_LANG_ru_RU = 16 , PSI_LANG_hu_HU = 17 , PSI_LANG_nl_NL = 18 , PSI_LANG_nl_BE = 19 ,
  PSI_LANG_en_AU = 20 , PSI_LANG_fr_BE = 21 , PSI_LANG_de_AT = 22 , PSI_LANG_en_NZ = 23 ,
  PSI_LANG_fr_CA = 24 , PSI_LANG_cs_CZ = 25 , PSI_LANG_sk_SK = 26 , PSI_LANG_pl_PL = 27 ,
  PSI_LANG_sl_SI = 28
}
 The known interface languages. More...
 
enum  batterystates { PSI_BATT_DEAD = 0 , PSI_BATT_VERYLOW = 1 , PSI_BATT_LOW = 2 , PSI_BATT_GOOD = 3 }
 The known battery states. More...
 
typedef struct rpcs::machineInfo_t machineInfo
 This struct holds the data returned by rpcs::getMachineInfo. More...
 

Public Member Functions

virtual ~rpcs ()
 Virtual destructor. More...
 
void reset ()
 Initializes a connection to the remote machine. More...
 
void reconnect ()
 Attempts to re-establish a remote connection by first closing the socket, then connecting again to the ncpd daemon and finally calling reset. More...
 
Enum< rfsv::errsgetStatus ()
 Retrieves the current status of the connection. More...
 
Enum< rfsv::errsgetNCPversion (int &major, int &minor)
 Retrieves the version of the NCP protocol on the remote side. More...
 
Enum< rfsv::errsexecProgram (const char *program, const char *args)
 Starts execution of a program on the remote machine. More...
 
Enum< rfsv::errsstopProgram (const char *program)
 Requests termination of a program running on the remote machine. More...
 
Enum< rfsv::errsqueryProgram (const char *)
 
Enum< rfsv::errsformatOpen (const char drive, int &handle, int &count)
 Starts formatting a drive. More...
 
Enum< rfsv::errsformatRead (int handle)
 Continues a running format. More...
 
Enum< rfsv::errsgetUniqueID (const char *, long &)
 
virtual Enum< rfsv::errsgetOwnerInfo (bufferArray &owner)=0
 Retrieve owner information of the remote machine. More...
 
Enum< rfsv::errsgetMachineType (Enum< machs > &type)
 Retrieves the type of machine on the remote side as defined in machs. More...
 
Enum< rfsv::errsfuser (const char *name, char *buf, int maxlen)
 Retrieves the name of a process, having a given file opened on the remote side. More...
 
Enum< rfsv::errsquitServer (void)
 Requests the remote server to terminate. More...
 
Enum< rfsv::errsqueryPrograms (processList &ret)
 Retrieves a list of all running Programs. More...
 
virtual Enum< rfsv::errsgetCmdLine (const char *process, std::string &ret)=0
 Retrieves the command line of a running process. More...
 
virtual Enum< rfsv::errsgetMachineInfo (machineInfo &machineInfo)
 Retrieve general Information about the connected machine. More...
 
virtual Enum< rfsv::errscloseHandle (uint32_t handle)
 Release an rpcs handle. More...
 
virtual Enum< rfsv::errsregOpenIter (uint32_t, char *, uint16_t &)
 
virtual Enum< rfsv::errsregReadIter (uint16_t)
 
virtual Enum< rfsv::errsregWrite (void)
 
virtual Enum< rfsv::errsregRead (void)
 
virtual Enum< rfsv::errsregDelete (void)
 
virtual Enum< rfsv::errssetTime (time_t time)
 
virtual Enum< rfsv::errsconfigRead (uint32_t size, bufferStore &data)
 Read from Series 5 scratch RAM. More...
 
virtual Enum< rfsv::errsconfigWrite (bufferStore data)
 Write to Series 5 scratch RAM. More...
 
virtual Enum< rfsv::errsqueryOpen (void)
 
virtual Enum< rfsv::errsqueryRead (void)
 

Protected Types

enum  commands {
  QUERY_NCP = 0x00 , EXEC_PROG = 0x01 , QUERY_DRIVE = 0x02 , STOP_PROG = 0x03 ,
  QUERY_PROG = 0x04 , FORMAT_OPEN = 0x05 , FORMAT_READ = 0x06 , GET_UNIQUEID = 0x07 ,
  GET_OWNERINFO = 0x08 , GET_MACHINETYPE = 0x09 , GET_CMDLINE = 0x0a , FUSER = 0x0b ,
  GET_MACHINE_INFO = 0x64 , CLOSE_HANDLE = 0x65 , REG_OPEN_ITER = 0x66 , REG_READ_ITER = 0x67 ,
  REG_WRITE = 0x68 , REG_READ = 0x69 , REG_DELETE = 0x6a , SET_TIME = 0x6b ,
  CONFIG_OPEN = 0x6c , CONFIG_READ = 0x6d , CONFIG_WRITE = 0x6e , QUERY_OPEN = 0x6f ,
  QUERY_READ = 0x70 , QUIT_SERVER = 0xff
}
 The possible commands. More...
 

Protected Member Functions

virtual Enum< rfsv::errsconfigOpen (uint16_t &handle, uint32_t size)
 Prepare scratch RAM in Series 5 for read/write. More...
 
bool sendCommand (enum commands cc, bufferStore &data)
 Sends a command to the remote side. More...
 
Enum< rfsv::errsgetResponse (bufferStore &data, bool statusIsFirstByte)
 
const char * getConnectName ()
 

Protected Attributes

TCPSocketskt
 The socket, used for communication with ncpd. More...
 
Enum< rfsv::errsstatus
 The current status of the connection. More...
 
int mtCacheS5mx
 Flag: getMachineType and getMachineInfo have been called and the machine is an S5mx. More...
 

Detailed Description

Remote procedure call services via PLP.

rpcs provides an interface for communicating with the Psion's remote procedure call service. The generic facilities for both, EPOC and SIBO are implemented here, while the facilities, unique to each of those variants are implemented in rpcs32 or rpcs16 respectively. These normally are instantiated by using rpcsfactory .

Author
Fritz Elfert felfe.nosp@m.rt@t.nosp@m.o.com

Definition at line 51 of file rpcs.h.

Member Typedef Documentation

◆ machineInfo

This struct holds the data returned by rpcs::getMachineInfo.

Member Enumeration Documentation

◆ batterystates

The known battery states.

Enumerator
PSI_BATT_DEAD 
PSI_BATT_VERYLOW 
PSI_BATT_LOW 
PSI_BATT_GOOD 

Definition at line 109 of file rpcs.h.

◆ commands

enum rpcs::commands
protected

The possible commands.

Enumerator
QUERY_NCP 
EXEC_PROG 
QUERY_DRIVE 
STOP_PROG 
QUERY_PROG 
FORMAT_OPEN 
FORMAT_READ 
GET_UNIQUEID 
GET_OWNERINFO 
GET_MACHINETYPE 
GET_CMDLINE 
FUSER 
GET_MACHINE_INFO 
CLOSE_HANDLE 
REG_OPEN_ITER 
REG_READ_ITER 
REG_WRITE 
REG_READ 
REG_DELETE 
SET_TIME 
CONFIG_OPEN 
CONFIG_READ 
CONFIG_WRITE 
QUERY_OPEN 
QUERY_READ 
QUIT_SERVER 

Definition at line 430 of file rpcs.h.

◆ languages

The known interface languages.

Enumerator
PSI_LANG_TEST 
PSI_LANG_en_GB 
PSI_LANG_fr_FR 
PSI_LANG_de_DE 
PSI_LANG_es_ES 
PSI_LANG_it_IT 
PSI_LANG_sv_SE 
PSI_LANG_da_DK 
PSI_LANG_no_NO 
PSI_LANG_fi_FI 
PSI_LANG_en_US 
PSI_LANG_fr_CH 
PSI_LANG_de_CH 
PSI_LANG_pt_PT 
PSI_LANG_tr_TR 
PSI_LANG_is_IS 
PSI_LANG_ru_RU 
PSI_LANG_hu_HU 
PSI_LANG_nl_NL 
PSI_LANG_nl_BE 
PSI_LANG_en_AU 
PSI_LANG_fr_BE 
PSI_LANG_de_AT 
PSI_LANG_en_NZ 
PSI_LANG_fr_CA 
PSI_LANG_cs_CZ 
PSI_LANG_sk_SK 
PSI_LANG_pl_PL 
PSI_LANG_sl_SI 

Definition at line 74 of file rpcs.h.

◆ machs

The known machine types.

Enumerator
PSI_MACH_UNKNOWN 
PSI_MACH_PC 
PSI_MACH_MC 
PSI_MACH_HC 
PSI_MACH_S3 
PSI_MACH_S3A 
PSI_MACH_WORKABOUT 
PSI_MACH_SIENA 
PSI_MACH_S3C 
PSI_MACH_S5 
PSI_MACH_WINC 

Definition at line 56 of file rpcs.h.

Constructor & Destructor Documentation

◆ ~rpcs()

rpcs::~rpcs ( )
virtual

Virtual destructor.

Definition at line 89 of file rpcs.cc.

Member Function Documentation

◆ closeHandle()

virtual Enum< rfsv::errs > rpcs::closeHandle ( uint32_t  handle)
inlinevirtual

Release an rpcs handle.

This function works with EPOC only. Using it with SIBO machines, returns always an error code E_PSI_NOT_SIBO. It releases a handle, obtained by a previous call to rpcs::configOpen .

Parameters
handleThe handle to close.
Returns
A psion error code. 0 = Ok.

Definition at line 365 of file rpcs.h.

◆ configOpen()

virtual Enum< rfsv::errs > rpcs::configOpen ( uint16_t &  handle,
uint32_t  size 
)
inlineprotectedvirtual

Prepare scratch RAM in Series 5 for read/write.

This function works with EPOC only. Using it with SIBO machines, returns always an error code E_PSI_NOT_SIBO. It prepares a scratch area on the EPOC machine for a following use from within rpcs::configRead or rpcs::configWrite . These functions call rpcs::closeHandle on exit. The contents of the scratch area is stored in RAM of the Series 5, therefore it gets lost when the Series 5 is switched off.

Parameters
handleThe handle to be used in rpcs::configRead , rpcs::configWrite and rpcs::closeHandle is returned here.
sizeThe number of bytes you want to use.
Returns
A psion error code. 0 = Ok.

Reimplemented in rpcs32.

Definition at line 483 of file rpcs.h.

◆ configRead()

virtual Enum< rfsv::errs > rpcs::configRead ( uint32_t  size,
bufferStore data 
)
inlinevirtual

Read from Series 5 scratch RAM.

This function works with EPOC only. Using it with SIBO machines, returns always an error code E_PSI_NOT_SIBO. It reads raw data from the scratch RAM of the Series 5.

Parameters
sizeThe amount of data to be read.
dataThe content of the scratch RAM is returned here.
Returns
A psion error code. 0 = Ok.

Reimplemented in rpcs32.

Definition at line 393 of file rpcs.h.

◆ configWrite()

virtual Enum< rfsv::errs > rpcs::configWrite ( bufferStore  data)
inlinevirtual

Write to Series 5 scratch RAM.

This function works with EPOC only. Using it with SIBO machines, returns always an error code E_PSI_NOT_SIBO. It writes raw data to the scatch RAM of the Series 5.

Parameters
dataThe data to be written to the scratch RAM.
Returns
A psion error code. 0 = Ok.

Reimplemented in rpcs32.

Definition at line 407 of file rpcs.h.

◆ execProgram()

Enum< rfsv::errs > rpcs::execProgram ( const char *  program,
const char *  args 
)

Starts execution of a program on the remote machine.

This function is working with both SIBO and EPOC devices.

Parameters
programThe full path of the executable on the remote machine
argsThe arguments for this program, separated by space.
Returns
A psion error code. 0 = Ok.

This is a hack for the jotter app on mx5 pro. (and probably others) Jotter seems to read its arguments one char past normal apps. Without this hack, The Drive-Character gets lost. Other apps don't seem to be hurt by the additional blank.

Definition at line 198 of file rpcs.cc.

◆ formatOpen()

Enum< rfsv::errs > rpcs::formatOpen ( const char  drive,
int &  handle,
int &  count 
)

Starts formatting a drive.

This function is working with both SIBO and EPOC devices. After calling formatOpen, formatRead should be called n times with the returned handle where n is the value of the returned parameter count.

Parameters
driveThe drive character to format (e.g: 'C', 'D' etc).
handleThe handle for calling formatRead is returned here.
countThe number of required calls to formatRead is returned here.
Returns
A psion error code. 0 = Ok.

Definition at line 322 of file rpcs.cc.

◆ formatRead()

Enum< rfsv::errs > rpcs::formatRead ( int  handle)

Continues a running format.

This function is working with both SIBO and EPOC devices. Call this function with the handle, returned by formatOpen.

Returns
A psion error code. 0 = Ok.

Definition at line 342 of file rpcs.cc.

◆ fuser()

Enum< rfsv::errs > rpcs::fuser ( const char *  name,
char *  buf,
int  maxlen 
)

Retrieves the name of a process, having a given file opened on the remote side.

This function is working with both SIBO and EPOC devices

Parameters
nameThe full path of a file to be checked for being used by a program.
bufA buffer which gets filled with the program's name.
maxlenThe maximum capacity of the buffer.

Definition at line 391 of file rpcs.cc.

◆ getCmdLine()

virtual Enum< rfsv::errs > rpcs::getCmdLine ( const char *  process,
std::string &  ret 
)
pure virtual

Retrieves the command line of a running process.

This function works with both SIBO and EPOC. Note: rpcs::queryPrograms calls this method internally and sets the args member of PsiProcess , so you usually don't have to call this method yourself.

Parameters
processName of process. Format: processname.$pid
retThe program name and arguments are returned here.
Returns
Psion error code. 0 = Ok.

Implemented in rpcs16, and rpcs32.

◆ getConnectName()

const char * rpcs::getConnectName ( void  )
protected

Definition at line 125 of file rpcs.cc.

◆ getMachineInfo()

virtual Enum< rfsv::errs > rpcs::getMachineInfo ( machineInfo machineInfo)
inlinevirtual

Retrieve general Information about the connected machine.

This function works with EPOC only. Using it with SIBO machines, returns always an error code E_PSI_NOT_SIBO.

Parameters
machineInfoThe struct holding all information on return.
Returns
Psion error code. 0 = Ok.

Reimplemented in rpcs32.

Definition at line 351 of file rpcs.h.

◆ getMachineType()

Enum< rfsv::errs > rpcs::getMachineType ( Enum< machs > &  type)

Retrieves the type of machine on the remote side as defined in machs.

This function is working with both SIBO and EPOC devices

Parameters
typeThe code describing the type of machine on the remote side is stored here on return.
Returns
A psion error code. 0 = Ok.

Definition at line 370 of file rpcs.cc.

◆ getNCPversion()

Enum< rfsv::errs > rpcs::getNCPversion ( int &  major,
int &  minor 
)

Retrieves the version of the NCP protocol on the remote side.

This function is working with both SIBO and EPOC devices.

Parameters
majorThe major part of the NCP version. Valid only if returned with no error.
minorThe minor part of the NCP version. Valid only if returned with no error.
Returns
A psion error code. 0 = Ok.

Definition at line 181 of file rpcs.cc.

◆ getOwnerInfo()

virtual Enum< rfsv::errs > rpcs::getOwnerInfo ( bufferArray owner)
pure virtual

Retrieve owner information of the remote machine.

This function is working with both SIBO and EPOC devices.

Parameters
ownerA bufferArray, containing the lines of the owner info upon return.
Returns
A psion error code. 0 = Ok.

Implemented in rpcs16, and rpcs32.

◆ getResponse()

Enum< rfsv::errs > rpcs::getResponse ( bufferStore data,
bool  statusIsFirstByte 
)
protected

Definition at line 156 of file rpcs.cc.

◆ getStatus()

Enum< rfsv::errs > rpcs::getStatus ( void  )

Retrieves the current status of the connection.

Returns
The connection status.

Definition at line 119 of file rpcs.cc.

◆ getUniqueID()

Enum< rfsv::errs > rpcs::getUniqueID ( const char *  device,
long &  id 
)

Definition at line 353 of file rpcs.cc.

◆ queryOpen()

virtual Enum< rfsv::errs > rpcs::queryOpen ( void  )
inlinevirtual

Definition at line 410 of file rpcs.h.

◆ queryProgram()

Enum< rfsv::errs > rpcs::queryProgram ( const char *  program)

Definition at line 235 of file rpcs.cc.

◆ queryPrograms()

Enum< rfsv::errs > rpcs::queryPrograms ( processList ret)

Retrieves a list of all running Programs.

This function works with both SIBO and EPOC.

Parameters
retThe list of currently running processes is returned here.
Returns
A psion error code. 0 = Ok.

Definition at line 246 of file rpcs.cc.

◆ queryRead()

virtual Enum< rfsv::errs > rpcs::queryRead ( void  )
inlinevirtual

Definition at line 412 of file rpcs.h.

◆ quitServer()

Enum< rfsv::errs > rpcs::quitServer ( void  )

Requests the remote server to terminate.

This function is working with both SIBO and EPOC devices. There is usually no need to call this function, because the remote server is automatically stopped on disconnect.

Returns
A psion error code. 0 = Ok.

Definition at line 409 of file rpcs.cc.

◆ reconnect()

void rpcs::reconnect ( void  )

Attempts to re-establish a remote connection by first closing the socket, then connecting again to the ncpd daemon and finally calling reset.

Definition at line 97 of file rpcs.cc.

◆ regDelete()

virtual Enum< rfsv::errs > rpcs::regDelete ( void  )
inlinevirtual

Definition at line 376 of file rpcs.h.

◆ regOpenIter()

virtual Enum< rfsv::errs > rpcs::regOpenIter ( uint32_t  ,
char *  ,
uint16_t &   
)
inlinevirtual

Reimplemented in rpcs32.

Definition at line 368 of file rpcs.h.

◆ regRead()

virtual Enum< rfsv::errs > rpcs::regRead ( void  )
inlinevirtual

Definition at line 374 of file rpcs.h.

◆ regReadIter()

virtual Enum< rfsv::errs > rpcs::regReadIter ( uint16_t  )
inlinevirtual

Reimplemented in rpcs32.

Definition at line 370 of file rpcs.h.

◆ regWrite()

virtual Enum< rfsv::errs > rpcs::regWrite ( void  )
inlinevirtual

Definition at line 372 of file rpcs.h.

◆ reset()

void rpcs::reset ( void  )

Initializes a connection to the remote machine.

Definition at line 104 of file rpcs.cc.

◆ sendCommand()

bool rpcs::sendCommand ( enum commands  cc,
bufferStore data 
)
protected

Sends a command to the remote side.

If communication fails, a reconnect is triggered and a second attempt to transmit the request is attempted. If that second attempt fails, the function returns an error and sets rpcs::status to E_PSI_FILE_DISC.

Parameters
ccThe command to execute on the remote side.
dataAdditional data for this command.
Returns
true on success, false on failure.

Definition at line 134 of file rpcs.cc.

◆ setTime()

virtual Enum< rfsv::errs > rpcs::setTime ( time_t  time)
inlinevirtual

Reimplemented in rpcs32.

Definition at line 378 of file rpcs.h.

◆ stopProgram()

Enum< rfsv::errs > rpcs::stopProgram ( const char *  program)

Requests termination of a program running on the remote machine.

This function is working with both SIBO and EPOC devices.

Parameters
program
Returns
A psion error code. 0 = Ok.

Definition at line 224 of file rpcs.cc.

Member Data Documentation

◆ mtCacheS5mx

int rpcs::mtCacheS5mx
protected

Flag: getMachineType and getMachineInfo have been called and the machine is an S5mx.

Definition at line 463 of file rpcs.h.

◆ skt

TCPSocket* rpcs::skt
protected

The socket, used for communication with ncpd.

Definition at line 420 of file rpcs.h.

◆ status

Enum<rfsv::errs> rpcs::status
protected

The current status of the connection.

Definition at line 425 of file rpcs.h.


The documentation for this class was generated from the following files: