Modified for W5500 Ethernet initialize
Fork of GMMP_mbed by
Network/TCPclient/Print.cpp@0:7e575e5f88ec, 2015-08-09 (annotated)
- Committer:
- lesmin
- Date:
- Sun Aug 09 14:11:35 2015 +0000
- Revision:
- 0:7e575e5f88ec
forked from GMMP
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lesmin | 0:7e575e5f88ec | 1 | #include "Print.h" |
lesmin | 0:7e575e5f88ec | 2 | #include "mbed.h" |
lesmin | 0:7e575e5f88ec | 3 | |
lesmin | 0:7e575e5f88ec | 4 | #include <stdio.h> |
lesmin | 0:7e575e5f88ec | 5 | #include <string.h> |
lesmin | 0:7e575e5f88ec | 6 | |
lesmin | 0:7e575e5f88ec | 7 | size_t Print::write(const uint8_t* buf, size_t size) { |
lesmin | 0:7e575e5f88ec | 8 | size_t ret = 0; |
lesmin | 0:7e575e5f88ec | 9 | while (size--) { |
lesmin | 0:7e575e5f88ec | 10 | ret += write(*buf++); |
lesmin | 0:7e575e5f88ec | 11 | } |
lesmin | 0:7e575e5f88ec | 12 | return ret; |
lesmin | 0:7e575e5f88ec | 13 | } |
lesmin | 0:7e575e5f88ec | 14 | |
lesmin | 0:7e575e5f88ec | 15 | size_t Print::print(const char* s) { |
lesmin | 0:7e575e5f88ec | 16 | return write((const uint8_t*)s, strlen(s)); |
lesmin | 0:7e575e5f88ec | 17 | } |
lesmin | 0:7e575e5f88ec | 18 | |
lesmin | 0:7e575e5f88ec | 19 | size_t Print::print(char c) { |
lesmin | 0:7e575e5f88ec | 20 | return write(c); |
lesmin | 0:7e575e5f88ec | 21 | } |
lesmin | 0:7e575e5f88ec | 22 | |
lesmin | 0:7e575e5f88ec | 23 | size_t Print::print(int n) { |
lesmin | 0:7e575e5f88ec | 24 | return print((long) n); |
lesmin | 0:7e575e5f88ec | 25 | } |
lesmin | 0:7e575e5f88ec | 26 | |
lesmin | 0:7e575e5f88ec | 27 | size_t Print::print(long n) { |
lesmin | 0:7e575e5f88ec | 28 | char buf[8 * sizeof(long) + 1]; |
lesmin | 0:7e575e5f88ec | 29 | snprintf(buf, sizeof(buf), "%ld", n); |
lesmin | 0:7e575e5f88ec | 30 | return print(buf); |
lesmin | 0:7e575e5f88ec | 31 | } |
lesmin | 0:7e575e5f88ec | 32 | |
lesmin | 0:7e575e5f88ec | 33 | // Digits are ignored for now |
lesmin | 0:7e575e5f88ec | 34 | size_t Print::print(double n, int digits) { |
lesmin | 0:7e575e5f88ec | 35 | char buf[65]; |
lesmin | 0:7e575e5f88ec | 36 | snprintf(buf, sizeof(buf), "%g", n); |
lesmin | 0:7e575e5f88ec | 37 | return print(buf); |
lesmin | 0:7e575e5f88ec | 38 | } |
lesmin | 0:7e575e5f88ec | 39 | |
lesmin | 0:7e575e5f88ec | 40 | size_t Print::println(const char* s) { |
lesmin | 0:7e575e5f88ec | 41 | return print(s) + println(); |
lesmin | 0:7e575e5f88ec | 42 | } |
lesmin | 0:7e575e5f88ec | 43 | |
lesmin | 0:7e575e5f88ec | 44 | size_t Print::println(char c) { |
lesmin | 0:7e575e5f88ec | 45 | return print(c) + println(); |
lesmin | 0:7e575e5f88ec | 46 | } |
lesmin | 0:7e575e5f88ec | 47 | |
lesmin | 0:7e575e5f88ec | 48 | size_t Print::println(int n) { |
lesmin | 0:7e575e5f88ec | 49 | return print(n) + println(); |
lesmin | 0:7e575e5f88ec | 50 | } |
lesmin | 0:7e575e5f88ec | 51 | |
lesmin | 0:7e575e5f88ec | 52 | size_t Print::println(long n) { |
lesmin | 0:7e575e5f88ec | 53 | return print(n) + println(); |
lesmin | 0:7e575e5f88ec | 54 | } |
lesmin | 0:7e575e5f88ec | 55 | |
lesmin | 0:7e575e5f88ec | 56 | size_t Print::println(double n, int digits) { |
lesmin | 0:7e575e5f88ec | 57 | return print(n, digits) + println(); |
lesmin | 0:7e575e5f88ec | 58 | } |
lesmin | 0:7e575e5f88ec | 59 | |
lesmin | 0:7e575e5f88ec | 60 | size_t Print::println() { |
lesmin | 0:7e575e5f88ec | 61 | return print('\r') + print('\n'); |
lesmin | 0:7e575e5f88ec | 62 | } |