スマートコンセント(富士通 FX-5204PS)をIEEE1888 StorageにWRITEするサンプルプログラムです。

Dependencies:   EthernetInterface FiapV2 HTTPClientForSOAP NTPClient TextLCD mbed-rtos mbed spxml

Fork of BlueUSB_f by Yasushi TAUCHI

スマートコンセント(富士通 FX-5204PS)をIEEE1888 StorageにWRITEするサンプルプログラムです。
USB HUBを使用して2台利用した例です。
表示のみは http://mbed.org/users/yueee_yt/code/BlueUSB_f/で公開しています。

BlueUSBより派生していますが、BluetoothとMass Storage Classは利用できません。

2台まで確認していますが、プログラム的には10台まで接続できるようにしています。
(RTOSとの整合により難しいかもしれません)

Utils.cpp

Committer:
yueee_yt
Date:
2012-09-30
Revision:
6:08a406cd2726
Parent:
0:606b230e5b4a

File content as of revision 6:08a406cd2726:



#include "mbed.h"
#include "Utils.h"

void printfBytes(const char* s, const u8* data, int len)
{
    printf("%s %d:",s,len);
    if (len > 256)
        len = 256;
    while (len-- > 0)
        printf(" %02X",*data++);
    printf("\n");
}

void printHexLine(const u8* d, int addr, int len)
{
    printf("%04X ",addr);
    int i;
    for (i = 0; i < len; i++)
        printf("%02X ",d[i]);
    for (;i < 16; i++)
        printf("   ");
    char s[16+1];
    memset(s,0,sizeof(s));
    for (i = 0; i < len; i++)
    {
        int c = d[i];
        if (c < 0x20 || c > 0x7E)
            c = '.';
        s[i] = c;
    }
    printf("%s\n",s);
}

void printHex(const u8* d, int len)
{
    int addr = 0;
    while (len)
    {
        int count = len;
        if (count > 16)
            count = 16;
        printHexLine(d+addr,addr,count);
        addr += 16;
        len -= count;
    }
}