To make up a packet in python, with this format:
1 Byte (seq)+ 1 Byte (length) + N Bytes data (data, n<255),
then it will be easy to just:
newdata = chr(seq)+chr(len(data)+data
then data will be just a sequence of chars.
Thursday, December 07, 2006
In order to convert char into int in C / C++, there are two methods,
1. to convert a string '1234' into integer 1234:
void main (void)
{
char c[4];
int i;
strcpy(c,"1234");
i = atoi(c);
}
2. to conver an ascii character 'q' into its decimal representation: 113
{
char c;
int i;
c='q';
i=(int)c;
}
then i will be 113.
1. to convert a string '1234' into integer 1234:
void main (void)
{
char c[4];
int i;
strcpy(c,"1234");
i = atoi(c);
}
2. to conver an ascii character 'q' into its decimal representation: 113
{
char c;
int i;
c='q';
i=(int)c;
}
then i will be 113.
Subscribe to:
Posts (Atom)