1
0
mirror of https://github.com/preble/libpinproc synced 2026-04-15 23:35:23 +02:00

Merge pull request #11 from tomlogic/dev

Merge outstanding commits to `dev`
This commit is contained in:
Gerry Stellenberg
2020-07-20 17:41:36 -05:00
committed by GitHub
11 changed files with 301 additions and 240 deletions

View File

@@ -13,12 +13,18 @@ if(POLICY CMP0015)
cmake_policy(SET CMP0015 OLD)
endif()
# allow relative paths in LINK_DIRECTORIES
if(POLICY CMP0081)
cmake_policy(SET CMP0081 OLD)
endif()
###
### Project settings
###
project(PINPROC)
set (CMAKE_CXX_STANDARD 11)
set(PINPROC_VERSION_MAJOR "2")
set(PINPROC_VERSION_MINOR "0")
set(PINPROC_VERSION "${PINPROC_VERSION_MAJOR}.${PINPROC_VERSION_MINOR}")
@@ -45,6 +51,7 @@ option(APPLE_UNIVERSAL_BIN "Apple: Build universal binary" OFF)
option(MSVC_SHARED_RT "MSVC: Build with shared runtime libs (/MD)" ON)
option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (/ML until VS .NET 2003)" OFF)
option(CROSS_ROOT "Cross-compilation root path" OFF)
###
### Sources, headers, directories and libs
@@ -69,8 +76,15 @@ if(VERBOSE)
endif()
# use -DEXTRA_INC="<path>;<path>" and -DEXTRA_LINK="<path>;<path>"
set(EXTRA_INC "" CACHE STRING "Extra include directories separated by ;")
set(EXTRA_LINK "" CACHE STRING "Extra link directories separated by ;")
if(CROSS_ROOT)
include_directories(${PINPROC_SOURCE_DIR}/include ${EXTRA_INC} ${CROSS_ROOT}/usr/local/include)
link_directories(${EXTRA_LINK} ${CROSS_ROOT}/usr/local/lib)
else()
include_directories(${PINPROC_SOURCE_DIR}/include ${EXTRA_INC} /usr/local/include)
link_directories(${EXTRA_LINK} /usr/local/lib)
endif()
set(YAML_CPP_LIB "yaml-cpp")
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}")
@@ -161,6 +175,9 @@ if(MSVC)
set(YAML_CPP_LIB "${CMAKE_STATIC_LIBRARY_PREFIX}${YAML_CPP_LIB}${LIB_RT_SUFFIX}")
set(YAML_CPP_LIB_DBG "${YAML_CPP_LIB}d")
endif()
else()
# make sure executable files are standalone
SET(CMAKE_EXE_LINKER_FLAGS "-static")
endif()

View File

@@ -10,7 +10,6 @@ LIBPINPROC_DYLIB = bin/libpinproc.dylib
SRCS = src/pinproc.cpp src/PRDevice.cpp src/PRHardware.cpp
OBJS := $(SRCS:.cpp=.o)
INCLUDES = include/pinproc.h src/PRCommon.h src/PRDevice.h src/PRHardware.h
LIBS = usb ftdi
.PHONY: libpinproc
libpinproc: $(LIBPINPROC) $(LIBPINPROC_DYLIB)
@@ -20,7 +19,7 @@ $(LIBPINPROC): $(OBJS)
$(RANLIB) $@
$(LIBPINPROC_DYLIB): $(OBJS)
g++ -dynamiclib -o $@ /usr/local/lib/libftdi.dylib $(LDFLAGS) $(OBJS)
g++ -dynamiclib -o $@ `pkg-config --libs libftdi1` $(LDFLAGS) $(OBJS)
.cpp.o:
$(CC) $(LIBPINPROC_CFLAGS) $(CFLAGS) -o $@ $<

View File

@@ -12,7 +12,7 @@ libpinproc requires:
- [libftdi-0.16](http://www.intra2net.com/en/developer/libftdi/): Install with the default /usr/local prefix.
The pinproctest example requires [yaml-cpp](http://code.google.com/p/yaml-cpp/). Follow the build instructions, creating the build subdirectory. After building, from the main source directory, run the following commands to manually install it:
The pinproctest example requires [yaml-cpp](https://github.com/jbeder/yaml-cpp). Follow the build instructions, creating the build subdirectory. After building, from the main source directory, run the following commands to manually install it:
sudo cp lib/libyaml-cpp.a /usr/local/lib/
sudo mkdir /usr/local/include/yaml-cpp

View File

@@ -46,12 +46,8 @@ PRResult LoadConfiguration(YAML::Node& yamlDoc, const char *yamlFilePath)
fprintf(stderr, "YAML file not found: %s\n", yamlFilePath);
return kPRFailure;
}
YAML::Parser parser(fin);
while(parser)
{
parser.GetNextDocument(yamlDoc);
}
yamlDoc = YAML::Load(fin);
}
// catch (YAML::ParserException& ex)
// {
@@ -341,8 +337,7 @@ int main(int argc, const char **argv)
return 1;
}
std::string machineTypeString;
yamlDoc["PRGame"]["machineType"] >> machineTypeString;
std::string machineTypeString = yamlDoc["PRGame"]["machineType"].as<std::string>();
if (machineTypeString == "wpc")
machineType = kPRMachineWPC;
else if (machineTypeString == "wpc95")

View File

@@ -142,36 +142,34 @@ void ConfigureSwitchRules(PRHandle proc, YAML::Node& yamlDoc)
// WPC Flippers
std::string numStr;
const YAML::Node& flippers = yamlDoc[kFlippersSection];
for (YAML::Iterator flippersIt = flippers.begin(); flippersIt != flippers.end(); ++flippersIt)
for (YAML::const_iterator flippersIt = flippers.begin(); flippersIt != flippers.end(); ++flippersIt)
{
int swNum, coilMain, coilHold;
std::string flipperName;
*flippersIt >> flipperName;
std::string flipperName = flippersIt->as<std::string>();
if (machineType == kPRMachineWPC)
{
yamlDoc[kSwitchesSection][flipperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> numStr; coilMain = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField] >> numStr; coilHold = PRDecode(machineType, numStr.c_str());
numStr = yamlDoc[kSwitchesSection][flipperName][kNumberField].as<std::string>(); swNum = PRDecode(machineType, numStr.c_str());
numStr = yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField].as<std::string>(); coilMain = PRDecode(machineType, numStr.c_str());
numStr = yamlDoc[kCoilsSection][flipperName + "Hold"][kNumberField].as<std::string>(); coilHold = PRDecode(machineType, numStr.c_str());
ConfigureWPCFlipperSwitchRule (proc, swNum, coilMain, coilHold, kFlipperPulseTime);
}
else if (machineType == kPRMachineSternWhitestar || machineType == kPRMachineSternSAM)
{
printf("hi\n");
yamlDoc[kSwitchesSection][flipperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField] >> numStr; coilMain = PRDecode(machineType, numStr.c_str());
numStr = yamlDoc[kSwitchesSection][flipperName][kNumberField].as<std::string>(); swNum = PRDecode(machineType, numStr.c_str());
numStr = yamlDoc[kCoilsSection][flipperName + "Main"][kNumberField].as<std::string>(); coilMain = PRDecode(machineType, numStr.c_str());
ConfigureSternFlipperSwitchRule (proc, swNum, coilMain, kFlipperPulseTime, kFlipperPatterOnTime, kFlipperPatterOffTime);
}
}
const YAML::Node& bumpers = yamlDoc[kBumpersSection];
for (YAML::Iterator bumpersIt = bumpers.begin(); bumpersIt != bumpers.end(); ++bumpersIt)
for (YAML::const_iterator bumpersIt = bumpers.begin(); bumpersIt != bumpers.end(); ++bumpersIt)
{
int swNum, coilNum;
// WPC Slingshots
std::string bumperName;
*bumpersIt >> bumperName;
yamlDoc[kSwitchesSection][bumperName][kNumberField] >> numStr; swNum = PRDecode(machineType, numStr.c_str());
yamlDoc[kCoilsSection][bumperName][kNumberField] >> numStr; coilNum = PRDecode(machineType, numStr.c_str());
std::string bumperName = bumpersIt->as<std::string>();
numStr = yamlDoc[kSwitchesSection][bumperName][kNumberField].as<std::string>(); swNum = PRDecode(machineType, numStr.c_str());
numStr = yamlDoc[kCoilsSection][bumperName][kNumberField].as<std::string>(); coilNum = PRDecode(machineType, numStr.c_str());
ConfigureBumperRule (proc, swNum, coilNum, kBumperPulseTime);
}
}

View File

@@ -138,6 +138,9 @@ PINPROC_API PRResult PRFlushWriteData(PRHandle handle);
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
PINPROC_API PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
/** Write data buffered to P-ROC (does require a call to PRFlushWriteData). */
PINPROC_API PRResult PRWriteDataUnbuffered(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer);
/** Read data from the P-ROC. */
PINPROC_API PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);

View File

@@ -265,10 +265,9 @@ PRResult PRDevice::ManagerUpdateConfig(PRManagerConfig *managerConfig)
{
const int burstWords = 2;
uint32_t burst[burstWords];
int32_t rc;
DEBUG(PRLog(kPRLogInfo, "Setting Manager Config Register\n"));
this->managerConfig = *managerConfig;
rc = CreateManagerUpdateConfigBurst(burst, managerConfig);
CreateManagerUpdateConfigBurst(burst, managerConfig);
return PrepareWriteData(burst, burstWords);
}
@@ -276,13 +275,12 @@ PRResult PRDevice::DriverUpdateGlobalConfig(PRDriverGlobalConfig *driverGlobalCo
{
const int burstWords = 4;
uint32_t burst[burstWords];
int32_t rc;
DEBUG(PRLog(kPRLogInfo, "Installing driver globals\n"));
this->driverGlobalConfig = *driverGlobalConfig;
rc = CreateDriverUpdateGlobalConfigBurst(burst, driverGlobalConfig);
rc = CreateWatchdogConfigBurst(burst+2, driverGlobalConfig->watchdogExpired,
CreateDriverUpdateGlobalConfigBurst(burst, driverGlobalConfig);
CreateWatchdogConfigBurst(burst+2, driverGlobalConfig->watchdogExpired,
driverGlobalConfig->watchdogEnable,
driverGlobalConfig->watchdogResetTime);
@@ -301,11 +299,10 @@ PRResult PRDevice::DriverUpdateGroupConfig(PRDriverGroupConfig *driverGroupConfi
{
const int burstWords = 2;
uint32_t burst[burstWords];
int32_t rc;
driverGroups[driverGroupConfig->groupNum] = *driverGroupConfig;
DEBUG(PRLog(kPRLogInfo, "Installing driver group\n"));
rc = CreateDriverUpdateGroupConfigBurst(burst, driverGroupConfig);
CreateDriverUpdateGroupConfigBurst(burst, driverGroupConfig);
DEBUG(PRLog(kPRLogVerbose, "Words: %x %x\n", burst[0], burst[1]));
return PrepareWriteData(burst, burstWords);
@@ -321,7 +318,6 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
{
const int burstWords = 3;
uint32_t burst[burstWords];
int32_t rc;
// Don't allow Constant Pulse (non-schedule with time = 0) for known high current drivers.
// Note, the driver numbers depend on the driver group settings from DriverLoadMachineTypeDefaults.
@@ -337,7 +333,7 @@ PRResult PRDevice::DriverUpdateState(PRDriverState *driverState)
drivers[driverState->driverNum] = *driverState;
rc = CreateDriverUpdateBurst(burst, &drivers[driverState->driverNum]);
CreateDriverUpdateBurst(burst, &drivers[driverState->driverNum]);
DEBUG(PRLog(kPRLogVerbose, "Words: %x %x %x\n", burst[0], burst[1], burst[2]));
return PrepareWriteData(burst, burstWords);
@@ -598,9 +594,8 @@ PRResult PRDevice::DriverWatchdogTickle()
{
const int burstWords = 2;
uint32_t burst[burstWords];
int32_t rc;
rc = CreateWatchdogConfigBurst(burst, driverGlobalConfig.watchdogExpired,
CreateWatchdogConfigBurst(burst, driverGlobalConfig.watchdogExpired,
driverGlobalConfig.watchdogEnable,
driverGlobalConfig.watchdogResetTime);
@@ -768,7 +763,6 @@ PRResult PRDevice::SwitchUpdateRule(uint8_t switchNum, PREventType eventType, PR
PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwitches )
{
uint32_t rc;
uint32_t stateWord, debounceWord;
uint8_t i, j;
PREventType eventType;
@@ -783,24 +777,24 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
if (chip_id == P_ROC_CHIP_ID)
{
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
if (combinedVersionRevision < P_ROC_VER_REV_FIXED_SWITCH_STATE_READS) {
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P_ROC_SWITCH_CTRL_OLD_DEBOUNCE_BASE_ADDR + i, 1);
}
else {
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
}
}
else // chip == P3_ROC_CHIP_ID)
{
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P3_ROC_SWITCH_CTRL_STATE_BASE_ADDR + i, 1);
rc = RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
RequestData(P_ROC_BUS_SWITCH_CTRL_SELECT,
P3_ROC_SWITCH_CTRL_DEBOUNCE_BASE_ADDR + i, 1);
}
}
@@ -816,8 +810,10 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
{
PRSleep (10); // 10 milliseconds should be plenty of time.
if (SortReturningData() != kPRSuccess)
{
return kPRFailure;
}
}
// Make sure all of the requested words are available before processing them.
// Too many words is just as bad as not enough words.
@@ -851,7 +847,11 @@ PRResult PRDevice::SwitchGetStates( PREventType * switchStates, uint16_t numSwit
}
return kPRSuccess;
}
else return kPRFailure;
else
{
PRSetLastErrorText("Switch response length does not match.");
return kPRFailure;
}
}
int32_t PRDevice::DMDUpdateConfig(PRDMDConfig *dmdConfig)
@@ -1093,6 +1093,7 @@ PRResult PRDevice::VerifyChipID()
DEBUG(PRLog(kPRLogError, "Error in VerifyID(): Dumping buffer\n"));
for (i = 0; i < bufferWords; i++)
DEBUG(PRLog(kPRLogError, "buffer[%d]: 0x%x\n", i, buffer[i]));
PRSetLastErrorText("Chip ID does not match.");
rc = kPRFailure;
}
else rc = kPRSuccess;
@@ -1111,6 +1112,7 @@ PRResult PRDevice::VerifyChipID()
}
else {
DEBUG(PRLog(kPRLogError, "Error reading Chip IP and Version. Read %d words instead of 5. The first 2 were: 0x%x and 0x%x.\n", requestedDataQueue.size(), buffer[0], buffer[1]));
PRSetLastErrorText("Error reading Chip IP and Version. Read %d words instead of 5. The first 2 were: 0x%x and 0x%x.", requestedDataQueue.size(), buffer[0], buffer[1]);
rc = kPRFailure;
}
}
@@ -1118,6 +1120,7 @@ PRResult PRDevice::VerifyChipID()
{
// Return failure without logging; calling function must log.
DEBUG(PRLog(kPRLogError, "Verify Chip ID took too long to receive data\n"));
PRSetLastErrorText("Verify Chip ID took too long to receive data");
rc = kPRFailure;
}
return (rc);
@@ -1179,10 +1182,6 @@ PRResult PRDevice::WriteData(uint32_t * words, int32_t numWords)
wr_buffer[(j*4)+k] = (uint8_t)(temp_word & 0x000000ff);
temp_word = temp_word >> 8;
}
// for (k=0; k<4; k++)
// {
// item = wr_buffer[(j*4)+k];
// }
}
int bytesToWrite = numWords * 4;
@@ -1199,6 +1198,19 @@ PRResult PRDevice::WriteData(uint32_t * words, int32_t numWords)
}
}
PRResult PRDevice::WriteDataRawUnbuffered(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{
PRResult res;
uint32_t * buffer;
buffer = (uint32_t *)malloc((numWriteWords * 4) + 4);
buffer[0] = CreateBurstCommand(moduleSelect, startingAddr, numWriteWords);
memcpy(buffer+1, writeBuffer, numWriteWords * 4);
res = PrepareWriteData(buffer, numWriteWords + 1);
free (buffer);
return res;
}
PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{
PRResult res;
@@ -1214,11 +1226,10 @@ PRResult PRDevice::WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, in
PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
{
uint32_t rc;
uint32_t i;
int32_t i;
// Send out the request.
rc = RequestData(moduleSelect, startingAddr, numReadWords);
RequestData(moduleSelect, startingAddr, numReadWords);
i = 0; // Reset i so it can be used to prevent an infinite loop below
@@ -1244,7 +1255,11 @@ PRResult PRDevice::ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int
}
return kPRSuccess;
}
else return kPRFailure;
else
{
PRSetLastErrorText("Response length did not match.");
return kPRFailure;
}
}
@@ -1273,6 +1288,7 @@ int32_t PRDevice::ReadData(uint32_t *buffer, int32_t num_words)
rc = num_words;
}
else {
PRSetLastErrorText("Read length did not match.");
rc = 0;
}
DEBUG(PRLog(kPRLogVerbose, "Read num bytes: %d\n", rc));
@@ -1281,10 +1297,9 @@ int32_t PRDevice::ReadData(uint32_t *buffer, int32_t num_words)
PRResult PRDevice::FlushReadBuffer()
{
int32_t numBytes,rc=0,k;
int32_t numBytes,rc=0;
//uint32_t rd_buffer[3];
numBytes = CollectReadData();
k = 0;
DEBUG(PRLog(kPRLogError, "Flushing Read Buffer: %d bytes trashed\n", numBytes));
//while (k < numBytes) {
@@ -1320,7 +1335,7 @@ int32_t PRDevice::CollectReadData()
PRResult PRDevice::SortReturningData()
{
int32_t num_bytes, num_words, rc;
int32_t num_bytes, num_words;
uint32_t rd_buffer[FTDI_BUFFER_SIZE/4];
num_bytes = CollectReadData();
@@ -1332,7 +1347,7 @@ PRResult PRDevice::SortReturningData()
num_words = num_collected_bytes/4;
while (num_words >= 2) {
rc = ReadData(rd_buffer, 1);
ReadData(rd_buffer, 1);
DEBUG(PRLog(kPRLogVerbose, "New returning word: 0x%x\n", rd_buffer[0]));
switch ( (rd_buffer[0] & P_ROC_COMMAND_MASK) >> P_ROC_COMMAND_SHIFT)

View File

@@ -60,6 +60,7 @@ public:
PRResult FlushWriteData();
PRResult WriteDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer);
PRResult WriteDataRawUnbuffered(uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * buffer);
PRResult ReadDataRaw(uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer);
PRResult ManagerUpdateConfig(PRManagerConfig *managerConfig);

View File

@@ -389,6 +389,7 @@ PRResult PRHardwareOpen()
ftStatus = FT_ListDevices(pcBufLD, &iNumDevs, FT_LIST_ALL | FT_OPEN_BY_SERIAL_NUMBER);
if(ftStatus != FT_OK) {
PRSetLastErrorText("FT_ListDevices(%d)\n", ftStatus);
DEBUG(PRLog(kPRLogInfo,"Error: FT_ListDevices(%d)\n", ftStatus));
return kPRFailure;
}
@@ -410,6 +411,7 @@ PRResult PRHardwareOpen()
also rmmod usbserial
*/
DEBUG(PRLog(kPRLogInfo,"Error FT_OpenEx(%d), device\n", ftStatus, i));
PRSetLastErrorText("Error FT_OpenEx(%d), device\n", ftStatus, i);
return kPRFailure;
}
@@ -429,7 +431,11 @@ PRResult PRHardwareOpen()
DEBUG(PRLog(kPRLogInfo,"FTDI Device Opened\n"));
return kPRSuccess;
}
else return kPRFailure;
else
{
PRSetLastErrorText("No FTDI device found.");
return kPRFailure;
}
}
void PRHardwareClose()

View File

@@ -119,12 +119,18 @@ PRResult PRFlushWriteData(PRHandle handle)
return handleAsDevice->FlushWriteData();
}
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData */
/** Write data out to the P-ROC immediately (does not require a call to PRFlushWriteData). */
PRResult PRWriteData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{
return handleAsDevice->WriteDataRaw(moduleSelect, startingAddr, numWriteWords, writeBuffer);
}
/** Write data buffered to P-ROC (does require a call to PRFlushWriteData). */
PRResult PRWriteDataUnbuffered(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numWriteWords, uint32_t * writeBuffer)
{
return handleAsDevice->WriteDataRawUnbuffered(moduleSelect, startingAddr, numWriteWords, writeBuffer);
}
/** Read data from the P-ROC. */
PRResult PRReadData(PRHandle handle, uint32_t moduleSelect, uint32_t startingAddr, int32_t numReadWords, uint32_t * readBuffer)
{

View File

@@ -2051,6 +2051,8 @@ int verifyP3ROCImage()
}
XSVFDBG_PRINTF( 0, "\n\nSUCCESS - Operation completed successfully. Cycle P3-ROC power to activate any changes.\n" );
return 1;
}
void writeP3ROCImage()
@@ -2134,13 +2136,10 @@ int processFile()
endClock = clock();
fclose( in );
// Destroy the P-ROC device handle:
PRDelete(proc);
proc = kPRHandleInvalid;
return iErrorCode;
}
int checkPROCFile() {
uint32_t checkPROCFile() {
uint32_t checksum=0, file_checksum, file_board_id, header_checksum;
unsigned char data;
int i=0,file_i=0;
@@ -2176,10 +2175,20 @@ int checkPROCFile() {
PRReadData(proc, 0, 0, 4, readdata);
board_id = readdata[0];
board_rev = readdata[3];
if (board_id == P3_ROC_CHIP_ID) {
board_rev = (board_rev & 0x800) >> 11 |
(board_rev & 0x400) >> 10 |
(board_rev & 0x200) >> 9 |
(board_rev & 0x100) >> 8;
fprintf(stderr, "\nReading P3-ROC board_rev: %d", board_rev);
}
else {
board_rev = (board_rev & 0x80) >> 7 |
(board_rev & 0x40) >> 5 |
(board_rev & 0x20) >> 3 |
(board_rev & 0x10) >> 1;
(board_rev & 0x40) >> 6 |
(board_rev & 0x20) >> 5 |
(board_rev & 0x10) >> 4;
fprintf(stderr, "\nReading P-ROC board_rev: %d", board_rev);
}
if (proc_file_version != 0) {
fprintf(stderr, "\nERROR: Unsupported .p-roc file version: %x. Check for an updated version of this tool.\n\n", proc_file_version);
@@ -2197,6 +2206,14 @@ int checkPROCFile() {
return 0;
}
else fprintf(stderr, "\nBoard ID verified");
if (board_rev > max_board_rev) {
fprintf(stderr, "\nERROR: board_rev %d > max_board_rev %d", board_rev, max_board_rev);
}
if (board_rev < min_board_rev) {
fprintf(stderr, "\nERROR: board_rev < min_board_rev");
}
if (board_rev > max_board_rev || board_rev < min_board_rev) {
fprintf(stderr, "\nERROR: This image is not compatible with the P-ROC board (rev: %x)", board_id);
return 0;
@@ -2303,8 +2320,12 @@ int main( int argc, char** argv )
processP3ROCFile();
break;
default:
fprintf(stderr, "Failed to parse file.\n");
break;
}
// Destroy the P-ROC device handle created by openPROC()
PRDelete(proc);
proc = kPRHandleInvalid;
}
}
}