Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 04:41, 30 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WISE Receive Number

From Wiki
Jump to: navigation, search
Article Metadata
Article
Created: ebra (17 Jun 2008)
Last edited: hamishwillee (30 May 2013)

Contents

Description

The communication between two WISE devices is devided into two possibilities

When number is send or received the data size is always 5 bytes - the first byte is a control byte (always 'L') and the remaining 4 bytes represents a 32 bit integer is a little endian format.

Maemo Platform

#define LITTLE_ENDIAN 'L'
#define BIG_ENDIAN 'R'
 
int buffer_to_int(const char* buffer,int* error)
{
int index,result=0;
*error=WISE_OK;
if ( buffer==NULL ) return 0;
if ( buffer[0]==LITTLE_ENDIAN )
{
for ( index=sizeof(int); index>1; index-- )
result=(result+(int)buffer[index])<<8;
result+=(int)buffer[1];
}
else if ( buffer[0]==BIG_ENDIAN )
{
for ( index=1; index < sizeof(int); index++ )
result=(result+(int)buffer[index])<<8;
result+=(int)buffer[sizeof(int)];
}
else *error=WISE_ERROR;
return result;
}
 
int wise_recv_int(int socket,int* nbr)
{
int bytes_read=0,error;
char number[sizeof(int)+1];
 
/* receive number */
bytes_read = read(socket,number,sizeof(int)+1);
if ( bytes_read < sizeof(int)+1 )
{
return WISE_CONNECTION_ERROR;
}
*nbr = buffer_to_int(number,&error);
return error;
}

S60 Platform

TInt CWISEBase::ReceiveIntL(RSocket& aSocket)
{
TRequestStatus status;
TBuf8<5> buffer;
TSockXfrLength len;
 
aSocket.RecvOneOrMore(buffer, 0, status, len);
User::WaitForRequest(status);
User::LeaveIfError(status.Int());
 
const TUint8* ptr = buffer.Ptr();
return LittleEndian::Get32(++ptr);
}

Links

This page was last modified on 30 May 2013, at 04:41.
64 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×