Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: Picaso_4DGL-32PTU_main.cpp
- Revision:
- 13:1a0800957412
- Parent:
- 12:29f5ad896382
- Child:
- 14:561cb06a2739
diff -r 29f5ad896382 -r 1a0800957412 Picaso_4DGL-32PTU_main.cpp
--- a/Picaso_4DGL-32PTU_main.cpp Wed Sep 14 13:27:37 2016 +0000
+++ b/Picaso_4DGL-32PTU_main.cpp Thu Sep 15 08:04:37 2016 +0000
@@ -24,8 +24,8 @@
//******************************************************************************************************
PICASO_4DGL :: PICASO_4DGL(PinName tx, PinName rx, PinName rst) : pc(USBTX, USBRX), _cmd(tx, rx), _rst(rst) { // Constructor
- rxBuf[RXBUFLEN] = 0; // create buffer
- buffer[BUFFER_SIZE] = 0;
+ //rxBuf[RXBUFLEN] = 0; // create buffer
+ //buffer[BUFFER_SIZE] = 0;
index = 0;
_cmd.attach(this, &PICASO_4DGL::rxCallback, Serial::RxIrq);
@@ -67,12 +67,7 @@
//******************************************************************************************************
void PICASO_4DGL :: rxCallback() {
- while(1) {
- if(_cmd.readable()) {
- rxBuf[index++] = _cmd.getc();
- break;
- }
- }
+ if(_cmd.readable()) rxBuf[index++] = _cmd.getc();
}
//******************************************************************************************************
@@ -103,7 +98,8 @@
#endif
int i;
freeBUFFER();
-
+ //index = 0;
+
for (i = 0; i < number; i++) writeBYTE(command[i]); // send command to serial port
}
@@ -210,7 +206,7 @@
#if DEBUGMODE
pc.printf("\n\r");
- pc.printf("New COMMAND : 0x%02X%02X\n\r", command[0], command[1]);
+ pc.printf("New BAUDRATE : 0x%02X%02X\n\r", command[0], command[1]);
#endif
int i;
@@ -329,26 +325,27 @@
while (index < count) {
wait_ms(100); // wait for screen answer
#if DEBUGMODE
- pc.printf(".");
+ //pc.printf(",");
#endif
}
#if DEBUGMODE
- pc.printf("\n\r");
+ pc.printf("\n\r DEBUG: Answer = ");
+ pc.printf("%02X %02X %02X\n\r", rxBuf[0], rxBuf[1], rxBuf[2]);
#endif
-#if DEBUGMODE
- pc.printf("\n\r DEBUG: Answer = ");
- for (int i = 0; i < index; i++) {
- pc.printf("%02X ", rxBuf[i]);
- }
- pc.printf("\n\r");
-#endif
int j = 3;
for (int i = 0; i < BUFFER_SIZE; i++) {
buffer[i] = rxBuf[j];
j++;
}
- if (rxBuf[0] == 0x06) {
+#if DEBUGMODE
+ pc.printf("\n\r DEBUG: Buffer = ");
+ for (int i = 0; i < BUFFER_SIZE; i++) {
+ pc.printf("%02X ", buffer[i]);
+ }
+ pc.printf("\n\r");
+#endif
+ if (rxBuf[2] == 1) {
index = 0; // set buffer index to 0
return true;
}