// ReadMemory.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "windows.h" #include "PACSDK.h" #include "stdlib.h" int main(int argc, char* argv[]) { if(argc < 4) { printf("ICPDAS (R) SDK Demo for XP-8000\n\n"); printf("usage: ReadMemory address dwLength mem_type \n\n"); printf("where\n"); printf(" address:\n"); printf(" - the memory address where read from.\n"); printf(" dwLength:\n"); printf(" - number of characters to be read.\n"); printf(" mem_type:\n"); printf(" - 0 SRAM\n"); printf(" - 1 EEPROM\n"); } else { BYTE buffer[4096]; BOOL err; char strErr[32]; memset(buffer, 0, 4096); if(atoi(argv[3]) == 0) { printf("The size of SRAM is %d\n", pac_GetMemorySize(atoi(argv[3]))); err = pac_ReadMemory(atoi(argv[1]), buffer, atoi(argv[2]), atoi(argv[3])); if(err == FALSE) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Read SRAM failure!. The error code is %x\n", pac_GetLastError()); printf("%s", strErr); return 0; } printf("%s\n", buffer); } else { printf("The size of EEPROM is %d\n", pac_GetMemorySize(atoi(argv[3]))); err = pac_ReadMemory(atoi(argv[1]), buffer, atoi(argv[2]), atoi(argv[3])); if(err == FALSE) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Read EEPROM failure!. The error code is %x\n", pac_GetLastError()); printf("%s", strErr); return 0; } printf("%s\n", buffer); } } return 0; }