BA / SerialCom

Fork of OmniWheels by Gustav Atmel

Revision:
2:798925c9e4a8
Parent:
1:9c5af431a1f1
--- a/SerialServerSend.cpp	Tue May 01 15:47:08 2018 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * SerialServer.cpp
- * Copyright (c) 2017, ZHAW
- * All rights reserved.
- *
- *  Created on: 05.06.2017
- *      Author: Marcel Honegger
- */
-
-#include <vector>
-#include <mbed.h>
-#include "SerialServerSend.h"
-
-
-using namespace std;
-
-const float SerialServerSend::PERIOD = 0.001f;     // the period of the timer interrupt, given in [s]
-/**
- * Create a serial server object.
- 
-
- 
-SerialServer::SerialServer(RawSerial& serial, StateMachine& stateMachine) : serial(serial), stateMachine(stateMachine), thread(osPriorityRealtime, STACK_SIZE) {
-*/
-SerialServerSend::SerialServerSend(RawSerial& serial) : serial(serial), thread(osPriorityRealtime, STACK_SIZE) { 
-    // initialize local values
-    
-    input.clear();
-    output.clear();
-    
-    // start thread and ticker timer interrupt service routine
-    
-    thread.start(callback(this, &SerialServerSend::run));
-    ticker.attach(callback(this, &SerialServerSend::sendSignal), PERIOD);
-}
-
-/**
- * Delete the serial server object and release all allocated resources.
- */
-SerialServerSend::~SerialServerSend() {
-    
-    ticker.detach();
-}
-
-/**
- * This method is called by the ticker timer interrupt service routine.
- * It sends a signal to the thread to make it run again.
- */
-void SerialServerSend::sendSignal() {
-    
-    thread.signal_set(signal);
-}
-
-/**
- * This <code>run()</code> method contains an infinite loop with the run logic.
- */
-void SerialServerSend::run() {
-    
-    Serial pc(PA_2, PA_3); // tx, rx
-    pc.baud(9600);
-    
-    while (true) {
-        
-        // wait for the periodic signal
-        
-        thread.signal_wait(signal);
-
-        if (output.size() == 0){
-            output += "Hello nicolas\n";
-        } 
-       
-        // transmit output
-        while (serial.writeable() && (output.size() > 0)) {
-            //pc.printf("Send To P: %s\r\n",output[0]);
-
-            serial.putc(output[0]);
-            output.erase(0, 1);
-        }
-    }
-    
-}