int main(int argc, char ** argv)
{
char hldFileName[256] = "pulser.hld";
- uint16_t trgNumber = 0;
+ unsigned int trgNumber = 0;
uint8_t triggerType = 0;
uint8_t input = 0;
unsigned int numEvts = UINT_MAX;
size = trb_ipu_data_read(triggerType, 0xcc, 0xdd, 0xaabb,
buffer, bufferSize);
if (size == -1) {
- fprintf(stderr, "Error IPU Read\n");
+ trb_error("Error IPU Read");
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
len = ((buffer[1] >> 16) & 0xffff) + 2;
- if (len >= size) {
+ if (len != size) {
fprintf(stderr, "DHRD len error, len=%d size=%d\n", len, size);
exit(EXIT_FAILURE);
}
- /*fprintf(stderr, "number padding zeros: %d\n", size - len);*/
+
if (writeToStdout == 1) {
fprintf(stdout, "Trigger# %d\n", trgNumber);
for (i = 0; i < len; i++) {
static const uint16_t trb_i2c_register = 0x8040;
-static const unsigned int timeout = 100;
+static const unsigned int timeout = 1000;
void usage(const char *progName)
{
int error = 0;
int i;
- while ((status = trb_register_read(trb_address, trb_i2c_register,
- buffer, BUFFER_SIZE)) == -1) {
- ctr++;
+ /* Wait until NoMoreData is withdrawn */
+ do {
+ if ((status = trb_register_read(trb_address, trb_i2c_register,
+ buffer, BUFFER_SIZE)) == -1) {
+ trb_error("Error I2C not ready");
+ return -1;
+ }
+
/* Check timeout */
if (ctr >= timeout) {
fprintf(stderr, "Error I2C not ready, timeout\n");
return -1;
}
-
- /* check trb_statusbits == no_more_data --> continue */
- if ((trb_errno == TRB_TERM_ERRBIT) &&
- (((trb_statusbits >> 16) & 0x0004) != 0)) {
- continue;
- }
- trb_error("Error I2C not ready");
- return -1;
- }
+ ctr++;
+ } while (trb_term.status_channel != 0);
if (checkStatus == 0) return status;
/* Check whether I2C is ready */
if (readI2CRegister(trb_address, 0, buffer, BUFFER_SIZE) == -1) {
+ trb_error("I2C not ready");
exit(EXIT_FAILURE);
}
clearI2C(trb_address);
exit(EXIT_FAILURE);
}
-
+
/* Wait for ACK */
if ((status = readI2CRegister(trb_address, 1, buffer, BUFFER_SIZE))
== -1) {
clearI2C(trb_address);
exit(EXIT_FAILURE);
}
-
+
/* Clear IC2 bus */
if (clearI2C(trb_address) == -1) {
exit(EXIT_FAILURE);