We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
I want to send control codes to a printer they look like this :
unsigned char cntrl_codes[6] = { 0x0d, 0x14, 0x1b, 0x4c, 0x0d, 0x0d};
//this function takes two arguments // 1)the array // 2)time delay between successive codes void print(unsigned char* c,unsigned char del) { int x,y; y=strlen(c);//y++; for(x=0;x<y;x++) { putchar(c[x]); delay(del); } }
It is not clear what the problem is. You could define your control codes as a null terminated string if you prefer:
unsigned char cntrl_codes = "\0x0d\0x14\0x1b\0x4c\0x0d\0x0d";
Try this:
void TxSerial(unsigned char *ptr) { while(*ptr!=0x0) { SBUF=*ptr; //Send one character while(!TI) //Wait for completion {} TI=0; //Clear Tx flag ptr++; } }
while(*ptr!=0x0)
Thanks All I am using a null-term array and it works fine.