mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-20 08:38:00 +02:00
merge from 4.0.1
This commit is contained in:
@ -31,6 +31,9 @@ int myport=-1;
|
||||
//struct sockaddr_in address;
|
||||
//#define VERBOSE
|
||||
|
||||
#define BLACKFIN_DRVR_SND_LMT (30000) // rough limit
|
||||
#define BLACKFIN_RSND_PCKT_LOOP (10)
|
||||
#define BLACKFIN_RSND_WAIT_US (1)
|
||||
|
||||
int bindSocket(unsigned short int port_number) {
|
||||
int i;
|
||||
@ -314,13 +317,46 @@ int receiveData(int file_des, void* buf,int length, intType itype){
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int sendDataOnly(int file_des, void* buf,int length) {
|
||||
int sendDataOnly(int file_des, void* buf,int length) {
|
||||
if (!length)
|
||||
return 0;
|
||||
int ret = write(file_des, buf, length); //value of -1 is other end socket crash as sigpipe is ignored
|
||||
if (ret < 0) cprintf(BG_RED, "Error writing to socket. Possible socket crash\n");
|
||||
return ret;
|
||||
|
||||
|
||||
int bytesSent = 0;
|
||||
int retry = 0; // retry index when buffer is blocked (write returns 0)
|
||||
while (bytesSent < length) {
|
||||
|
||||
// setting a max packet size for blackfin driver (and network driver does not do a check if packets sent)
|
||||
int bytesToSend = length - bytesSent;
|
||||
if (bytesToSend > BLACKFIN_DRVR_SND_LMT)
|
||||
bytesToSend = BLACKFIN_DRVR_SND_LMT;
|
||||
|
||||
// send
|
||||
int rc = write(file_des, (char*)((char*)buf + bytesSent), bytesToSend);
|
||||
// error
|
||||
if (rc < 0) {
|
||||
cprintf(BG_RED, "Error writing to socket. Possible socket crash: left=%d rc=%d length=%d sent=%d\n", bytesToSend, rc, length, bytesSent);
|
||||
return bytesSent;
|
||||
}
|
||||
// also error, wrote nothing, buffer blocked up, too fast sending for client
|
||||
if (rc == 0) {
|
||||
cprintf(RED, "Error writing to socket. Buffer full. Retry: %d\n", retry);
|
||||
++retry;
|
||||
// wrote nothing for many loops
|
||||
if (retry >= BLACKFIN_RSND_PCKT_LOOP) {
|
||||
cprintf(BG_RED, "Error writing to socket. Buffer full! Too fast! No more.\n");
|
||||
return bytesSent;
|
||||
}
|
||||
usleep(BLACKFIN_RSND_WAIT_US);
|
||||
}
|
||||
// wrote something, reset retry
|
||||
else {
|
||||
retry = 0;
|
||||
}
|
||||
bytesSent += rc;
|
||||
}
|
||||
|
||||
return bytesSent;
|
||||
}
|
||||
|
||||
|
||||
|
@ -378,6 +378,8 @@ enum dacIndex {
|
||||
M_vIbiasSh, /**< mythen 3 >*/
|
||||
M_vIcin, /**< mythen 3 >*/
|
||||
M_vIpreOut, /**< mythen 3 >*/
|
||||
ZMQ_emin, /**< ZMQ */
|
||||
ZMQ_emax,/**< ZMQ */
|
||||
V_POWER_A = 100, /**new chiptest board */
|
||||
V_POWER_B = 101, /**new chiptest board */
|
||||
V_POWER_C = 102, /**new chiptest board */
|
||||
@ -473,13 +475,28 @@ enum readOutFlags {
|
||||
READ_HITS=0x2, /**< return only the number of the channel which counted ate least one */
|
||||
ZERO_COMPRESSION=0x4,/**< returned data are 0-compressed */
|
||||
PUMP_PROBE_MODE=0x8,/**<pump-probe mode */
|
||||
|
||||
PEDESTAL=0x10,/**< frame mode set to pedestal */
|
||||
FLAT=0x20,/**< frame mode set to flat */
|
||||
NEWPEDESTAL=0x40,/**< frame mode set to pedestal and reset */
|
||||
NEWFLAT=0x80,/**< frame mode set to flat and reset */
|
||||
|
||||
FRAME=0x100, /**< frame mode set to normal frame */
|
||||
ANALOG=0x200, /**<detector working in analog mode */
|
||||
COUNTING=0x400, /**<detector working in counting mode */
|
||||
INTERPOLATING=0x800, /**<detector working in interpolating mode */
|
||||
|
||||
|
||||
|
||||
BACKGROUND_CORRECTIONS=0x1000, /**<background corrections */
|
||||
TOT_MODE=0x2000,/**< pump-probe mode */
|
||||
CONTINOUS_RO=0x4000,/**< pump-probe mode */
|
||||
|
||||
PARALLEL=0x10000,/**< eiger parallel mode */
|
||||
NONPARALLEL=0x20000,/**< eiger serial mode */
|
||||
SAFE=0x40000/**< eiger safe mode */,
|
||||
DIGITAL_ONLY=0x80000, /** chiptest board read only digital bits (not adc values)*/
|
||||
|
||||
ANALOG_AND_DIGITAL=0x100000, /** chiptest board read adc values and digital bits digital bits */
|
||||
DUT_CLK=0x200000, /** chiptest board fifo clock comes from device under test */
|
||||
SHOW_OVERFLOW=0x400000, /** eiger 32 bit mode, show saturated for overflow of single subframes */
|
||||
|
Reference in New Issue
Block a user