示例#1
0
void SerialMonitorService::begin()
{
  #if SAMD_SERIES
    stream = &Serial1;
  #else
    stream = &Serial;
  #endif

  setBPS(115200);
}
示例#2
0
int main(int argc, char const **argv) {

    char file[120];
    char mode [3];

    if (argv[1] == NULL)
    {
        printf("Boot needs at lest 1 argument\n");
        exit(EXIT_FAILURE);
    } else
    {
        strcpy(file, argv[1]);
    }

    if (argv[2] == NULL) {
        strcpy(mode, "r");
    } else
    {
        strcpy(mode, argv[2]);
    }

    //memcpy(shrmem.fileSysTyp, buf + 54, 8);
    memcpy(&shrmem.mode, &mode, 2);
    //memcpy(shrmem.fileSysTyp, buf + 54, 8);
//    memcpy(&shrmem.mode, &mode, (strlen(mode) * sizeof(char *)));
    FILE_SYSTEM_ID = fopen(file, mode);
    setFSID(FILE_SYSTEM_ID);

    shl_shareMemoryGet();


    unsigned char* buf;
    buf = malloc(BYTES_TO_READ_IN_BOOT_SECTOR);

    setBPS(BYTES_TO_READ_IN_BOOT_SECTOR);


    if (read_sector(0, buf) == -1){
        printf("Something has gone wrong -- could not read the shrmem sector\n");
    }

    shrmem.bytesPerSector = getWord(buf, 11);
    setBPS(shrmem.bytesPerSector);
    shrmem.sectorsPerCluster = getByte(buf, 13);
    shrmem.numResSector = getWord(buf, 14 );
    shrmem.numFat = getByte(buf, 16);
    shrmem.maxRootDirEnt = getWord(buf, 17);
    shrmem.totSectCount = getWord(buf, 19);
    shrmem.sectPerFat = getWord(buf, 22);
    shrmem.sectPerTrack = getWord(buf, 24);
    shrmem.numHead = getWord(buf, 26);
    shrmem.totSectCount4Fat = getDWord(buf, 32);
    shrmem.bootSig = getByte(buf, 38);
    shrmem.volID = getDWord(buf, 39);


    shrmem.volLabel[11] = 0;
    shrmem.fileSysTyp[8] = 0;
    memcpy(shrmem.volLabel, buf + 43, 11);
    memcpy(shrmem.fileSysTyp, buf + 54, 8);

    free(buf);


    shrmem.fildes = fileno(FILE_SYSTEM_ID);

    shl_shareMemorySet();

    fclose(FILE_SYSTEM_ID);

    return 0;
}