Mettre le caractère x2 après le résultat de la chaine reçue
Bonjour,
Je voudrais mettre le caractère x2 après le résultat de la chaine reçu qui est ici ps ou pu8String.
Après de multiples tentatives, je demande votre aide.
Je vous remercie d'avance.
O.B
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
/****************************************************************************
*
* NAME: vSerial_Init
*
* DESCRIPTION:
*
* PARAMETERS: Name RW Usage
* None.
*
* RETURNS:
* None.
*
* NOTES:
* None.
****************************************************************************/
PUBLIC void vSerialRxString(uint8 *ps)
{
uint8 *pu8String;
int16 i16Chr;
int16 X;
int16 str;
/* Copy the received string from the receive queue */
/*str = (char)ps; */
/*strcat (str,"x2") ;*/
/* ps = (uint8)str;*/
for(pu8String = ps; ((i16Chr = i16Serial_RxChar()) != (int16)RX_STRING_END_CHAR); pu8String++)
{
/* X = strcat ((uint8)i16Chr,"x2") ; */
*pu8String = (uint8)i16Chr;
/* X =strcat (*pu8String,"x2") ; */
}
/* *pu8String = (uint8)'x'; /* Append x2 character to the end of the string */
/* *pu8String = (uint8)'2'; /* Append x2 character to the end of the string */
/* *pu8String = (uint8)'x2'; */ /* Append x2 character to the end of the string */
*pu8String = (uint8)'\0'; /* Append NULL character to the end of the string */
} |
Error : error: assignment of read-only location <unnamed>::g_namesmap
Bonjour,
Je vous remercie de votre aide, ceci est du c++ et non du c.
Je n'arrive toujours pas à afficher les caractères x et 2 après la chaîne. Ce qui me préoccupe pour l'instant est qu'au moment de la compuilation j'ai 3 erreurs : assignment of read-only location <unnamed>::g_namesmap.
Les 3 erreurs pointent sur les lignes :
*pu8String = (uint8)'x'; /* Append 'x' character to the end of the string */
*pu8String = (uint8)'2'; /* Append '2' character to the end of the string */
*pu8String = (uint8)'\0'; /* Append NULL character to the end of the string */
PUBLIC void vSerial_TxString(const uint8 *ps)
{
const uint8 *pu8String;
uint8 *tmp;
for ( *tmp = ps; *tmp != 0 ; ++ tmp ) ; //tmp pointera sur le '\0',
//tmp - ps donne la taille de la chaîne sans compter le '\0' final ou tmp - ps + 1 pour le compter
*++ tmp = 0x02 ; //+1 à la longueur de la chaine
/* créér et allouer la chaîne pu8String avec une taille de ps-tmp+3 */
pu8String = (uint8*)malloc((tmp-ps+3) *sizeof(uint8)); /* ou alors: pu8String = (uint8 *)malloc(tmps-ps+3); */
*pu8String = (uint8)'x'; /* Append 'x' character to the end of the string */
*pu8String = (uint8)'2'; /* Append '2' character to the end of the string */
*pu8String = (uint8)'\0'; /* Append NULL character to the end of the string */
for(pu8String = ps; (!bSerialQ_Full(TX_QUEUE) && (*pu8String != TX_STRING_END_CHAR)); pu8String++)
{
vSerialQ_AddItem(TX_QUEUE, *pu8String); /* Add character to the transmit queue. */
}
vUART_StartTx(); /* Start the tx process if it has stalled */
}
Si vous avez des idées , merci beaucoup car là je suis coincé.
Merci d'avance.
Olivier
Ne fonctionne toujours pas
Bonsoir,
effectivement, après avoir enlever le 'const' dans les déclarations, je n'ai plus d'erreur.
Malheureusement, les caractères 'x' et '2' ne n'apparaissent toujours pas derrière la chaîne.
Si une personne d'entre vous vois une erreur, je lui en serait très reconnaissant.
Merci bien.
Olivier