Ok, its function is ok at my ICP, whatever, some times next execute it,
the program send to socket ....... when i try to send OPSL.
The functions actual on ICP:
Code:
void EscreveDisplay (unsigned char *pMensagem, unsigned int pDelaySec){
unsigned char cDispPacote [52];
int iComDisplay = 2;
unsigned int iLims;
unsigned int iLenMsg, iLenCont, iContIndex;
int iBcc;
iDisplaySend = 1;
if (pDelaySec > 0)
Delay(pDelaySec * 1000);
iLims = 46;
cDispPacote [0] = 129;
cDispPacote [1] = 126;
cDispPacote [2] = iLims % 256;
cDispPacote [3] = iLims / 256;
cDispPacote [4] = 1 % 256;
cDispPacote [5] = 1 / 256;
cDispPacote [6] = 0 % 256;
cDispPacote [7] = 0 / 256;
cDispPacote [8] = 76;
cDispPacote [9] = 202;
iLenMsg = strlen (pMensagem);
if (iLenMsg > 40)
iLenMsg = 40;
if (iLenMsg < 40){
for(iLenCont=iLenMsg; iLenCont<40; iLenCont++)
strcat (pMensagem, ".");
}
for(iLenCont=0; iLenCont<40; iLenCont++){
iContIndex = iLenCont + 10;
cDispPacote [iContIndex] = pMensagem [iLenCont];
}
iBcc = cDispPacote [4];
cDispPacote [50] = iBcc;
cDispPacote [51] = '\0';
for(iContIndex=0; iContIndex<=51; iContIndex++){
ToCom (iComDisplay, cDispPacote[iContIndex]);
}
iDisplaySend=0;
}
this function in pc, not is ok, all crazy chars in cDispPacote
I try change to this:
Code:
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void EscreveDisplay (unsigned char *pMensagem, unsigned int pDelaySec);
void main(void)
{
EscreveDisplay ("SERGIO", 0);
}
void EscreveDisplay (unsigned char *pMensagem, unsigned int pDelaySec){
unsigned char cDispPacote [52];
unsigned int iLims;
unsigned int iLenMsg, iLenCont, iContIndex;
int iBcc;
iLims = 46;
cDispPacote [0] = 129;
cDispPacote [1] = 126;
cDispPacote [2] = iLims % 256;
cDispPacote [3] = iLims / 256;
cDispPacote [4] = 1 % 256;
cDispPacote [5] = 1 / 256;
cDispPacote [6] = 0 % 256;
cDispPacote [7] = 0 / 256;
cDispPacote [8] = 76;
cDispPacote [9] = 202;
iLenMsg = strlen (pMensagem);
for (iLenCont=10; iLenCont<=49; iLenCont++)
cDispPacote [iLenCont] = '.';
for(iLenCont=0; iLenCont<iLenMsg; iLenCont++){
iContIndex = iLenCont + 10;
cDispPacote [iContIndex] = pMensagem [iLenCont];
}
iBcc = cDispPacote [4];
cDispPacote [50] = iBcc;
cDispPacote [51] = '\0';
printf ("Linha 1: \n");
for(iContIndex=0; iContIndex<=51; iContIndex++){
printf ("[%i] %c\n",iContIndex,cDispPacote[iContIndex]);
}
printf ("\n");
getch ();
}
Like some this, but in pc is ok, but no in my ICP
:S