int clip_COM_INIT(ClipMachine * mp) { v24_port_t *gz; int ret = -1, *err; int fd = _clip_parni(mp, 1); int baud = 9600, data = 8, stop = 1; char *parity = "N"; if (fd < 1 || fd > 32) return EG_ARG; fd = keys[fd]; gz = (v24_port_t *) _clip_fetch_c_item(mp, fd, _C_ITEM_TYPE_COMPORT); if (!gz) return EG_ARG; if (_clip_parinfo(mp, 2) == NUMERIC_t) baud = _clip_parni(mp, 2); if (_clip_parinfo(mp, 3) == CHARACTER_t) parity = _clip_parc(mp, 3); if (_clip_parinfo(mp, 4) == NUMERIC_t) data = _clip_parni(mp, 4); if (_clip_parinfo(mp, 5) == NUMERIC_t) stop = _clip_parni(mp, 5); err = _clip_fetch_item(mp, HASH_ferror); ret = v24SetParameters(gz, baud_val(baud), data_val(data), parity_val(parity)); _clip_retl(mp, ret ? 0 : 1); return 0; }
LogDefer::~LogDefer() { struct timeval end_tv; gettimeofday(&end_tv, NULL); o_.emplace("end", time_delta(&end_tv, &start_tv_)); if (!data_.empty()) { picojson::value data_val(data_); o_.emplace("data", data_val); } if (!logs_.empty()) { picojson::value logs_val(logs_); o_.emplace("logs", logs_val); } if (!timers_.empty()) { picojson::value timers_val(timers_); o_.emplace("timers", timers_val); } picojson::value v(o_); callback_(v.serialize()); }