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:
- 4:50511ed54ab4
- Parent:
- 3:dcfbceb81fef
- Child:
- 5:890ddd974624
diff -r dcfbceb81fef -r 50511ed54ab4 Picaso_4DGL-32PTU_main.cpp
--- a/Picaso_4DGL-32PTU_main.cpp Fri Sep 09 10:19:54 2016 +0000
+++ b/Picaso_4DGL-32PTU_main.cpp Fri Sep 09 12:45:28 2016 +0000
@@ -19,16 +19,15 @@
#include "mbed.h"
#include "Picaso_4DGL-32PTU.h"
-//Serial pc(USBTX,USBRX);
-DigitalOut led1(LED1), led2(LED2);
-#define SHORT_WAIT 500
-#define LONG_WAIT 2000
+DigitalOut led1(LED1);
//******************************************************************************************************
PICASO_4DGL :: PICASO_4DGL(PinName tx, PinName rx, PinName rst) : pc(USBTX, USBRX), _cmd(tx, rx), _rst(rst) { // Constructor
-
-responseBuild(10, '0');
-
+
+ rxBuf[bufLen]; // create buffer
+
+ responseBuild(10);
+
#if DEBUGMODE
pc.baud(115200);
@@ -49,7 +48,7 @@
#if DEBUGMODE
pc.printf("set baudrate to 9600...\n\r");
#endif
- baudrate(115200);
+ baudrate(9600);
#if DEBUGMODE
pc.printf("clear screen...\n\r");
@@ -70,9 +69,9 @@
}
//******************************************************************************************************
-void PICASO_4DGL :: responseBuild(int size, char c) {
+void PICASO_4DGL :: responseBuild(int size) {
- response[size] = c;
+ response[size] = 0;
respLen = 0;
}
@@ -236,23 +235,22 @@
//**************************************************************************
void PICASO_4DGL :: getResponse() {
- while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer
-
+ //clearResponse();
+ int k = 0, temp = 0, resp = 0;
+ char response[1] = "";
+
+ while (!_cmd.readable()) wait_ms(TEMPO); // wait for screen answer
+
while (_cmd.readable()) {
- resp = _cmd.getc(); // read response if any
- }
- switch (resp) {
- case ACK :
- pc.printf("\n\r Answer received : ACK");
- break;
- case NACK :
- pc.printf("\n\r Answer received : NACK");
- break;
- default :
- pc.printf("\n\r Answer received : UNKNOWN");
- break;
+ // temp = ;
+ response[resp++] = _cmd.getc();
}
+ pc.printf("\n\r RESP = %d\n\r", resp);
+ while (k < resp) {// print everything
+ pc.printf(" Response: %02X ", response[k++]);
+ }
+ pc.printf("\n\r");
}
@@ -287,3 +285,9 @@
writeCOMMAND(command, 4);
}
+
+//**************************************************************************
+void PICASO_4DGL :: clearResponse() {
+ for (int i = 0; i < 10; i++)
+ response[i] = '0';
+}
\ No newline at end of file