void bgrewriteaofCommand(redisClient *c) { if (server.aof_child_pid != -1) { addReplyError(c,"Background append only file rewriting already in progress"); } else if (server.rdb_child_pid != -1) { server.aof_rewrite_scheduled = 1; addReplyStatus(c,"Background append only file rewriting scheduled"); } else if (rewriteAppendOnlyFileBackground() == REDIS_OK) { addReplyStatus(c,"Background append only file rewriting started"); } else { addReply(c,shared.err); } }
void LengthenDelay(client *c, int argc, sds *argv) { int ret= Lengthen(argv[1]); if(ret==0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
void countReset(client *c, int argc, sds *argv) { uint32_t reset; safe_strtoul(argv[1],&reset); counterReset(reset); addReplyStatus(c, "+OK"); }
/* Output the representation of a Redis command. Used by the COMMAND command. */ static void addReplyCommand(client *c, struct redisCommand *cmd) { if (!cmd) { addReply(c, shared.nullbulk); } else { /* We are adding: command name, arg count, flags, first, last, offset */ addReplyMultiBulkLen(c, 6); addReplyBulkCString(c, cmd->name); addReplyLongLong(c, cmd->arity); int flagcount = 0; void *flaglen = addDeferredMultiBulkLength(c); flagcount += addReplyCommandFlag(c,cmd,CMD_WRITE, "write"); flagcount += addReplyCommandFlag(c,cmd,CMD_READONLY, "readonly"); flagcount += addReplyCommandFlag(c,cmd,CMD_DENYOOM, "denyoom"); flagcount += addReplyCommandFlag(c,cmd,CMD_ADMIN, "admin"); flagcount += addReplyCommandFlag(c,cmd,CMD_PUBSUB, "pubsub"); flagcount += addReplyCommandFlag(c,cmd,CMD_NOSCRIPT, "noscript"); flagcount += addReplyCommandFlag(c,cmd,CMD_RANDOM, "random"); flagcount += addReplyCommandFlag(c,cmd,CMD_SORT_FOR_SCRIPT,"sort_for_script"); flagcount += addReplyCommandFlag(c,cmd,CMD_LOADING, "loading"); flagcount += addReplyCommandFlag(c,cmd,CMD_STALE, "stale"); flagcount += addReplyCommandFlag(c,cmd,CMD_SKIP_MONITOR, "skip_monitor"); flagcount += addReplyCommandFlag(c,cmd,CMD_ASKING, "asking"); flagcount += addReplyCommandFlag(c,cmd,CMD_FAST, "fast"); if (cmd->getkeys_proc) { addReplyStatus(c, "movablekeys"); flagcount += 1; } setDeferredMultiBulkLength(c, flaglen, flagcount); addReplyLongLong(c, cmd->firstkey); addReplyLongLong(c, cmd->lastkey); addReplyLongLong(c, cmd->keystep); } }
// Trigger Commands void countLatch(client *c, int argc, sds *argv) { uint32_t latch; safe_strtoul(argv[1],&latch); counterLatch(latch); addReplyStatus(c, "+OK"); }
void SetSpeakerMask(client *c, int argc, sds *argv) { uint32_t mask; safe_strtoul(argv[1],&mask); speakerMask(mask); addReplyStatus(c, "+OK"); }
void SetAllowableClockMisses(client *c, int argc, sds *argv) { uint32_t nMisses; safe_strtoul(argv[1],&nMisses); ClockMisses(nMisses); addReplyStatus(c, "+OK"); }
void SetSpeakerScale(client *c, int argc, sds *argv) { uint32_t rate; safe_strtoul(argv[1],&rate); speakerScale(rate); addReplyStatus(c, "+OK"); }
void countMode(client *c, int argc, sds *argv) { uint32_t mode; safe_strtoul(argv[1],&mode); counterMode(mode); addReplyStatus(c, "+OK"); }
void typeCommand(redisClient *c) { robj *o; char *type; o = lookupKeyRead(c->db,c->argv[1]); if (o == NULL) { type = "none"; } else { switch(o->type) { case REDIS_STRING: type = "string"; break; case REDIS_LIST: type = "list"; break; case REDIS_SET: type = "set"; break; case REDIS_ZSET: type = "zset"; break; case REDIS_HASH: type = "hash"; break; default: type = "unknown"; break; } } addReplyStatus(c,type); }
// DAC Settings void SetDACThreshold(client *c, int argc, sds *argv) { uint32_t dacThresh; safe_strtoul(argv[1],&dacThresh); DACThresholds(dacThresh); addReplyStatus(c, "+OK"); }
/* Helper function for addReplyCommand() to output flags. */ static int addReplyCommandFlag(client *c, struct redisCommand *cmd, int f, char *reply) { if (cmd->flags & f) { addReplyStatus(c, reply); return 1; } return 0; }
// Control register void SetControlReg(client *c, int argc, sds *argv) { uint32_t cReg; safe_strtoul(argv[1],&cReg); ControlReg(cReg); addReplyStatus(c, "+OK"); }
void SetTriggerMask(client *c, int argc, sds *argv) { uint32_t mask, mask_async; safe_strtoul(argv[1],&mask); safe_strtoul(argv[2],&mask_async); triggerMask(mask,mask_async); addReplyStatus(c, "+OK"); }
// DGT & LO void SetGTDelays(client *c, int argc, sds *argv) { uint32_t loDelay, dgtDelay; safe_strtoul(argv[1],&loDelay); safe_strtoul(argv[2],&dgtDelay); GTDelays(loDelay, dgtDelay); addReplyStatus(c, "+OK"); }
// CAEN Settings void SetCaenWords(client *c, int argc, sds *argv) { uint32_t gPath, cSelect; safe_strtoul(argv[1],&gPath); safe_strtoul(argv[2],&cSelect); CAENWords(gPath, cSelect); addReplyStatus(c, "+OK"); }
// Utility commands void MZHappy(client *c, int argc, sds *argv) { // Set for 1e9 pulses. Should renew this in the status readout. int ret= Pulser(1,0.5,1e9,MappedHappyBaseAddress); if(ret == 0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
void SetComboTrigger(client *c, int argc, sds *argv) { u32 enableMask, logicMask; safe_strtoul(argv[1],&enableMask); safe_strtoul(argv[2],&logicMask); if(comboTrig(enableMask,logicMask) == 0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
//// Shift Register commands // Low level stuff void dataready(client *c, int argc, sds *argv) { uint32_t dReady; safe_strtoul(argv[1],&dReady); int ret= DataReady(dReady); if(ret==0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
void muxer(client *c, int argc, sds *argv) { uint32_t mux; safe_strtoul(argv[1],&mux); int ret= Muxer(mux); if(ret == 0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
// Clock commands void clockreset(client *c, int argc, sds *argv) { int ret= clockReset(1); usleep(1000); ret= clockReset(0); if(ret != 0) addReplyError(c, tubii_err); else addReplyStatus(c, "+OK"); }
void loadShift(client *c, int argc, sds *argv) { uint32_t lShift; safe_strtoul(argv[1],&lShift); int ret= LoadShift(lShift); if(ret == 0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
void gtdelay(client *c, int argc, sds *argv) { float length=0; safe_strtof(argv[1],&length); u32 delay = length*ns; int ret= Delay(delay,MappedGTDelayBaseAddress); if(ret == 0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
void SetPrescaleTrigger(client *c, int argc, sds *argv) { float rate; uint32_t bit; safe_strtof(argv[1],&rate); safe_strtoul(argv[2],&bit); if(prescaleTrig(rate,bit) == 0) addReplyStatus(c, "+OK"); else addReplyError(c, tubii_err); }
// Initialisation functions void initialise(client *c, int argc, sds *argv) { // Calls auto_init which: // -Maps all the memory // -Sets registers auto_init(); // Need to check for errors addReplyStatus(c, "+OK"); }
void bgsaveCommand(redisClient *c) { if (server.bgsavechildpid != -1) { addReplyError(c,"Background save already in progress"); } else if (server.bgrewritechildpid != -1) { addReplyError(c,"Can't BGSAVE while AOF log rewriting is in progress"); } else if (rdbSaveBackground(server.dbfilename) == REDIS_OK) { addReplyStatus(c,"Background saving started"); } else { addReply(c,shared.err); } }
void bgrewriteaofCommand(redisClient *c) { if (server.bgrewritechildpid != -1) { addReplyError(c,"Background append only file rewriting already in progress"); return; } if (rewriteAppendOnlyFileBackground() == REDIS_OK) { addReplyStatus(c,"Background append only file rewriting started"); } else { addReply(c,shared.err); } }
void bgsaveCommand(redisClient *c) { if (server.bgsavechildpid != -1) { addReplyError(c,"Background save already in progress"); return; } if (rdbSaveBackground(server.dbfilename) == REDIS_OK) { addReplyStatus(c,"Background saving started"); } else { addReply(c,shared.err); } }
void SetECalBit(client *c, int argc, sds *argv) { uint32_t cReg; safe_strtoul(argv[1],&cReg); if(cReg==1 || cReg==0){ ControlReg((mReadReg((u32) MappedRegsBaseAddress, RegOffset10) & 4294967291) + 4*cReg); addReplyStatus(c, "+OK"); } else{ addReplyError(c, "ECals can only be set on (1) or off (0)."); } }
void SetTrigWordDelay(client *c, int argc, sds *argv) { float length=0; safe_strtof(argv[1],&length); u32 delay = length*ns; int ret= TrigWordDelay(delay); if(ret!=0){ addReplyError(c, tubii_err); return; } addReplyStatus(c, "+OK"); }