stingr lib for v8_1

Committer:
jmoreno10
Date:
Mon Oct 29 12:45:27 2018 +0000
Revision:
0:0159aa4d2062
v8_1 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmoreno10 0:0159aa4d2062 1 /*
jmoreno10 0:0159aa4d2062 2 * mbed STINGR library
jmoreno10 0:0159aa4d2062 3 * Copyright (c) 2018
jmoreno10 0:0159aa4d2062 4 *
jmoreno10 0:0159aa4d2062 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
jmoreno10 0:0159aa4d2062 6 * of this software and associated documentation files (the "Software"), to deal
jmoreno10 0:0159aa4d2062 7 * in the Software without restriction, including without limitation the rights
jmoreno10 0:0159aa4d2062 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jmoreno10 0:0159aa4d2062 9 * copies of the Software, and to permit persons to whom the Software is
jmoreno10 0:0159aa4d2062 10 * furnished to do so, subject to the following conditions:
jmoreno10 0:0159aa4d2062 11 *
jmoreno10 0:0159aa4d2062 12 * The above copyright notice and this permission notice shall be included in
jmoreno10 0:0159aa4d2062 13 * all copies or substantial portions of the Software.
jmoreno10 0:0159aa4d2062 14 *
jmoreno10 0:0159aa4d2062 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jmoreno10 0:0159aa4d2062 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jmoreno10 0:0159aa4d2062 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jmoreno10 0:0159aa4d2062 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jmoreno10 0:0159aa4d2062 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jmoreno10 0:0159aa4d2062 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jmoreno10 0:0159aa4d2062 21 * THE SOFTWARE.
jmoreno10 0:0159aa4d2062 22 */
jmoreno10 0:0159aa4d2062 23
jmoreno10 0:0159aa4d2062 24 #ifndef MBED_STINGR_H
jmoreno10 0:0159aa4d2062 25 #define MBED_STINGR_H
jmoreno10 0:0159aa4d2062 26
jmoreno10 0:0159aa4d2062 27 #include "mbed.h"
jmoreno10 0:0159aa4d2062 28 #include "rtos.h"
jmoreno10 0:0159aa4d2062 29
jmoreno10 0:0159aa4d2062 30 class Stingr {
jmoreno10 0:0159aa4d2062 31
jmoreno10 0:0159aa4d2062 32 public:
jmoreno10 0:0159aa4d2062 33
jmoreno10 0:0159aa4d2062 34 // Constructor
jmoreno10 0:0159aa4d2062 35 Stingr();
jmoreno10 0:0159aa4d2062 36
jmoreno10 0:0159aa4d2062 37 // Accessors
jmoreno10 0:0159aa4d2062 38 const char* get_resp() const;
jmoreno10 0:0159aa4d2062 39
jmoreno10 0:0159aa4d2062 40 // Mutators
jmoreno10 0:0159aa4d2062 41 void setPacketByte(int incomingByte);
jmoreno10 0:0159aa4d2062 42
jmoreno10 0:0159aa4d2062 43 // Serial Packet processing functions
jmoreno10 0:0159aa4d2062 44 void clearPacket();
jmoreno10 0:0159aa4d2062 45 void printPacket();
jmoreno10 0:0159aa4d2062 46 void waitCTS();
jmoreno10 0:0159aa4d2062 47 void postCommand();
jmoreno10 0:0159aa4d2062 48 void command(char* com);
jmoreno10 0:0159aa4d2062 49 void execute(char* com);
jmoreno10 0:0159aa4d2062 50
jmoreno10 0:0159aa4d2062 51 // STINGR command functions
jmoreno10 0:0159aa4d2062 52 void query_ESN(); // command 'a'
jmoreno10 0:0159aa4d2062 53 void query_Bursts(); // command 'b'
jmoreno10 0:0159aa4d2062 54 void query_Firmware(); // command 'c'
jmoreno10 0:0159aa4d2062 55 void query_Setup(); // command 'd'
jmoreno10 0:0159aa4d2062 56 void query_Hardware(); // command 'e'
jmoreno10 0:0159aa4d2062 57 void NAK_command(); // command 'f'
jmoreno10 0:0159aa4d2062 58 void _setup(char* b); // command 'g'
jmoreno10 0:0159aa4d2062 59 void send_Data(char* b); // command 'h'
jmoreno10 0:0159aa4d2062 60 void abort_Transmission(); // command 'i'
jmoreno10 0:0159aa4d2062 61
jmoreno10 0:0159aa4d2062 62 // Additional functions
jmoreno10 0:0159aa4d2062 63 uint16_t ModRTU_CRC(char* buf, int len);
jmoreno10 0:0159aa4d2062 64
jmoreno10 0:0159aa4d2062 65 //*TEST
jmoreno10 0:0159aa4d2062 66 void respuesta();
jmoreno10 0:0159aa4d2062 67 void PC_communication();
jmoreno10 0:0159aa4d2062 68
jmoreno10 0:0159aa4d2062 69 int flag;
jmoreno10 0:0159aa4d2062 70 int incomingByte;
jmoreno10 0:0159aa4d2062 71 int num;
jmoreno10 0:0159aa4d2062 72
jmoreno10 0:0159aa4d2062 73 int incomingByteR;
jmoreno10 0:0159aa4d2062 74 char incomingByteX;
jmoreno10 0:0159aa4d2062 75 char strx[200];
jmoreno10 0:0159aa4d2062 76
jmoreno10 0:0159aa4d2062 77 Thread t1;
jmoreno10 0:0159aa4d2062 78 Thread t2;
jmoreno10 0:0159aa4d2062 79
jmoreno10 0:0159aa4d2062 80 private:
jmoreno10 0:0159aa4d2062 81 char _resp[200];
jmoreno10 0:0159aa4d2062 82 int _packet[15];
jmoreno10 0:0159aa4d2062 83 };
jmoreno10 0:0159aa4d2062 84
jmoreno10 0:0159aa4d2062 85 #endif
jmoreno10 0:0159aa4d2062 86