Arianna autonomous DAQ firmware

Dependencies:   mbed SDFileSystemFilinfo AriSnProtocol NetServicesMin AriSnComm MODSERIAL PowerControlClkPatch DS1820OW

Committer:
uci1
Date:
Fri Jul 20 19:04:02 2012 +0000
Revision:
1:e392595b4b76
Child:
3:24c5f0f50bf1
many features checked and working. afar implemented. sending of data not yet tested. contains many debug prints

Who changed what in which revision?

UserRevisionLine numberNew contents of line
uci1 1:e392595b4b76 1 /*
uci1 1:e392595b4b76 2 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
uci1 1:e392595b4b76 3
uci1 1:e392595b4b76 4 Permission is hereby granted, free of charge, to any person obtaining a copy
uci1 1:e392595b4b76 5 of this software and associated documentation files (the "Software"), to deal
uci1 1:e392595b4b76 6 in the Software without restriction, including without limitation the rights
uci1 1:e392595b4b76 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
uci1 1:e392595b4b76 8 copies of the Software, and to permit persons to whom the Software is
uci1 1:e392595b4b76 9 furnished to do so, subject to the following conditions:
uci1 1:e392595b4b76 10
uci1 1:e392595b4b76 11 The above copyright notice and this permission notice shall be included in
uci1 1:e392595b4b76 12 all copies or substantial portions of the Software.
uci1 1:e392595b4b76 13
uci1 1:e392595b4b76 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
uci1 1:e392595b4b76 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
uci1 1:e392595b4b76 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
uci1 1:e392595b4b76 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
uci1 1:e392595b4b76 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
uci1 1:e392595b4b76 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
uci1 1:e392595b4b76 20 THE SOFTWARE.
uci1 1:e392595b4b76 21 */
uci1 1:e392595b4b76 22
uci1 1:e392595b4b76 23 #ifndef BASE64_H
uci1 1:e392595b4b76 24 #define BASE64_H
uci1 1:e392595b4b76 25
uci1 1:e392595b4b76 26 #include <stdint.h>
uci1 1:e392595b4b76 27 /*
uci1 1:e392595b4b76 28 #include <string>
uci1 1:e392595b4b76 29 using std::string;
uci1 1:e392595b4b76 30 */
uci1 1:e392595b4b76 31
uci1 1:e392595b4b76 32 #ifdef __cplusplus
uci1 1:e392595b4b76 33 extern "C" {
uci1 1:e392595b4b76 34 #endif
uci1 1:e392595b4b76 35
uci1 1:e392595b4b76 36 //Originaly from Rolf's iputil.h
uci1 1:e392595b4b76 37
uci1 1:e392595b4b76 38 //uint32_t base64enc_len(const uint32_t slen);
uci1 1:e392595b4b76 39 //uint32_t base64enc_len(const int8_t* str);
uci1 1:e392595b4b76 40
uci1 1:e392595b4b76 41 #define BASE64ENC_LEN(slen) ( ((((slen)-1)/3)+1)<<2 )
uci1 1:e392595b4b76 42
uci1 1:e392595b4b76 43 void base64enc(const char *input, uint32_t length, char *output);
uci1 1:e392595b4b76 44
uci1 1:e392595b4b76 45 #ifdef __cplusplus
uci1 1:e392595b4b76 46 }
uci1 1:e392595b4b76 47 #endif
uci1 1:e392595b4b76 48
uci1 1:e392595b4b76 49 /*
uci1 1:e392595b4b76 50 class Base64
uci1 1:e392595b4b76 51 {
uci1 1:e392595b4b76 52 public:
uci1 1:e392595b4b76 53 static uint32_t base64enc_len(const string& str)
uci1 1:e392595b4b76 54 {
uci1 1:e392595b4b76 55 //return (((str.length()-1)/3)+1)<<2;
uci1 1:e392595b4b76 56 return base64enc_len(str.length());
uci1 1:e392595b4b76 57 }
uci1 1:e392595b4b76 58
uci1 1:e392595b4b76 59 static
uci1 1:e392595b4b76 60 void encode(const int8_t* in, const uint32_t len, int8_t* out) {
uci1 1:e392595b4b76 61 base64enc(in, len, out);
uci1 1:e392595b4b76 62 }
uci1 1:e392595b4b76 63
uci1 1:e392595b4b76 64 static string encode(const string& str)
uci1 1:e392595b4b76 65 {
uci1 1:e392595b4b76 66 int8_t* out = new int8_t[ base64enc_len(str) ];
uci1 1:e392595b4b76 67 base64enc(str.c_str(), str.length(), out);
uci1 1:e392595b4b76 68 string res(out);
uci1 1:e392595b4b76 69 delete[] out;
uci1 1:e392595b4b76 70 return res;
uci1 1:e392595b4b76 71 }
uci1 1:e392595b4b76 72 };
uci1 1:e392595b4b76 73 */
uci1 1:e392595b4b76 74
uci1 1:e392595b4b76 75 #endif