// WriteMemory.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: WriteMemory address value mem_type \n\n"); printf("where\n"); printf(" address:\n"); printf(" - the memory address where write to.\n"); printf(" value:\n"); printf(" - the data to be written to the memory.\n"); printf(" mem_type:\n"); printf(" - 0 SRAM\n"); printf(" - 1 EEPROM\n"); } else { BOOL err; char strErr[32]; if(atoi(argv[3]) == 0) { printf("The size of SRAM is %d\n", pac_GetMemorySize(atoi(argv[3]))); err = pac_WriteMemory(atoi(argv[1]), (unsigned char *)argv[2], strlen(argv[2]), atoi(argv[3])); if(err == FALSE) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Write SRAM failure!. The error code is %x\n", pac_GetLastError()); printf("%s", strErr); return 0; } printf("The write value is %s", argv[2]); } else { printf("The size of EEPROM is %d\n", pac_GetMemorySize(atoi(argv[3]))); pac_EnableEEPROM(TRUE); err = pac_WriteMemory(atoi(argv[1]), (unsigned char *)argv[2], strlen(argv[2]), atoi(argv[3])); if(err == FALSE) { pac_GetErrorMessage(pac_GetLastError(), strErr); printf("Write EEPROM failure!. The error code is %x\n", pac_GetLastError()); printf("%s", strErr); return 0; } pac_EnableEEPROM(FALSE); printf("The write value is %s", argv[2]); } } return 0; }