Merge pull request #11 from yoboujon/simon

recuperationParam et int2String
This commit is contained in:
Yohan Boujon 2023-01-18 10:31:39 +01:00 committed by GitHub
commit df63755693
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 4 deletions

View file

@ -27,4 +27,6 @@ int convertion(int nbr,char *numbuffer);
int gestionOffset(char *actualMessage,int encadrementHaut,int encadrementBas,int nbr);
int testProtocol(void);
int recuperationParam(char * msgParam);
int int2String(char *msgParam, int offset);
#endif

View file

@ -7,7 +7,7 @@ int main (int argc, char **argv)
{
char usageChar[100]="usage: cmd [-p|-s]|[-u][-u|-r ##|-e ##|-b][-n ##][-l ##] port ipAdress\n";
testProtocol();
bal();
//bal();
char *ipAddress;
extern char *optarg;
extern int optind;

View file

@ -83,14 +83,53 @@ int exitMax(int var,int tailleMax){
int testProtocol(void)
{
char * msg;
char * msg,*msg2;
msg=formatTextParam(7, 8, 64, 1);
printf("%s\n",msg);
msg=formatTextMessage("aaaaaa",6);
printf("%s\n",msg);
msg2=formatTextMessage("aaaaaa",6);
printf("%s\n",msg2);
recuperationParam(msg);
return 0;
}
int recuperationParam(char * msgParam)
{
int messageOrPram;
int numEmetteurParam;
int numRecepeteurParam;
int numTailleMessageParam;
int nbMessageParam;
printf("Message param %s\n",msgParam);
messageOrPram=msgParam[0]-0x30;
printf("messageOrPram = %d \n",messageOrPram);
numEmetteurParam = int2String(msgParam,1);
printf("Param Emetteur = %d\n",numEmetteurParam);
numRecepeteurParam= int2String(msgParam,5);
printf("Param numRecepeteurParam = %d\n",numRecepeteurParam);
numTailleMessageParam= int2String(msgParam,9);
printf("Param numTailleMessageParam = %d\n",numTailleMessageParam);
nbMessageParam=int2String(msgParam,13);
printf("Param nbMessageParam = %d\n",nbMessageParam);
return 0;
}
int int2String(char *msgParam, int offset)
{
int taille =4;
char buffEntier[taille];
for(int i=offset,j=0;i<=offset+taille;i++,j++){
buffEntier[j]=msgParam[i];
}
return atoi(buffEntier);
}
char * formatTextParam(int numEmetteur, int numRecepteur, int tailleMessage, int nbMessage)
{