bosko lekovic
/
EthTCPclient_05_01
p1
Revision 7:0939ac3d73af, committed 2020-06-18
- Comitter:
- bosko001
- Date:
- Thu Jun 18 15:20:34 2020 +0000
- Parent:
- 6:19e7658575fe
- Commit message:
- p1
Changed in this revision
PGSdisplay.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 19e7658575fe -r 0939ac3d73af PGSdisplay.cpp --- a/PGSdisplay.cpp Mon Feb 24 17:14:44 2020 +0000 +++ b/PGSdisplay.cpp Thu Jun 18 15:20:34 2020 +0000 @@ -10,47 +10,87 @@ DigitalOut tast(PTB19,0); ////RawSerial rs485(PTC17,PTC16); -RawSerial rs485(PTD3,PTD2); +Serial rs485(PTD3,PTD2); +DigitalOut led(LED2,1); + + char cc; + + -void ev(int) +void rc(void) +{ + led = !led; + cc=rs485.getc(); +} + +void tast_on( int ) +{ +// rs485.attach( NULL, Serial::RxIrq ); + tast = 1; + } + +void tast_off(void) { tast=0; + // rs485.attach( rc, Serial::RxIrq ); } + + +#define FLAG_1 1 +EventFlags ef; + + uint8_t rs[100]; void init_disp( void) { - rs485.format(8,RawSerial::Even,1); - while(rs485.readable()) - { - rs485.read(rs,1,NULL); - } - putOnDisp("elcom", 3); - int i =0; - //while(rs485.readable()==0); - wait(0.5); - if(rs485.readable()) - { - - rs485.read(rs+i,1,NULL); - i++; - } - printf("ODGOVOR: %X - %d\n\r",rs[0],i); - //int i=0; -// -// printf("%d\n\r",rs485.readable()); -// if(rs485.readable()) -// { -// printf("\n\rRECEIVE: "); -// while(rs485.readable()) -// { -// rs[i++] = rs485.getc(); -// } -// printf("%X: RECEIVED %d: \n\r",rs[0], i); -// } + rs485.format(8,SerialBase::Even,1); +// rs485.attach( tast_off, Serial::TxIrq ); +// rs485.attach( rc, Serial::RxIrq ); + + +// rs485.enable_input(true); +// if(rs485.readable()) rs485.getc(); + + + //printf("ODGOVOR: %x \n\r",rs485.getc()); + + putOnDisp("elcom", 3); +printf("slanje na displej \n\r"); +//wait(0.010); +// rs485.attach( (rc), Serial::RxIrq ); +//printf("attachovanje \n\r"); + +//wait(0.110); +//// while(!rs485.readable()); +////printf("readable gotov \n\r"); +//fflush(stdout); +// +char c[10]; +int i,j=1; + //{ i=rs485.read( (uint8_t*)c,5, /*callback(ve)*/NULL ); j++;} + +//while( !(i=rs485.read( (uint8_t*)&c,1, callback(ve),SERIAL_EVENT_RX_COMPLETE )) ){j++;}; +//i=rs485.read( (uint8_t*)&c,1, callback(ve),SERIAL_EVENT_RX_COMPLETE ) ; + //printf("ODGOVOR: c=%x %x i=%x j=%d\n\r", c[0],c[1], i, j ); + + printf("primljeno cc =%x \n\r", cc); + + + + + // char c = rs485.getc(); + // wait(0.5); +//thread_sleep_for(500); +//printf("odgovor = %x\n\r", cc); + +//uint8_t c; +// if( rs485.readable()) printf("ODGOVOR: %d %x\n\r",rs485.read( &c, 1, ve), c); + } + unsigned char buf_tel[100] = {0x71,0x00,0x0D,0x71,0x43,DISP_ADR,0x1B,0x4A,0x01,0x01, /*0x1b,0x45,0x1,*/ 0x1B,0x43,1,0x33,0xD5,0x16}; #define NO_BEFORE_DATA 13 #define NO_WITH_DATA (NO_BEFORE_DATA + strlen(s)) @@ -72,9 +112,9 @@ buf_tel[2]=ubb; - tast=1; - rs485.write(buf_tel, NO_WITH_DATA+2+2,ev); - + tast_on(1); +// rs485.write((const void*)buf_tel, (size_t)(NO_WITH_DATA+2+2)/*, tast_off, SERIAL_EVENT_TX_COMPLETE*/); + for(int i=0; i< NO_WITH_DATA+2+2; i++ ) rs485.putc(buf_tel[i]); } void putOnDispNo(int broj, char boja)
diff -r 19e7658575fe -r 0939ac3d73af main.cpp --- a/main.cpp Mon Feb 24 17:14:44 2020 +0000 +++ b/main.cpp Thu Jun 18 15:20:34 2020 +0000 @@ -83,7 +83,7 @@ int main(void) { - +printf("Pocetak \n\r"); fflush(stdout); init_disp( );