本文整理汇总了C++中rdr_debug_mask函数的典型用法代码示例。如果您正苦于以下问题:C++ rdr_debug_mask函数的具体用法?C++ rdr_debug_mask怎么用?C++ rdr_debug_mask使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rdr_debug_mask函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cardreader_do_checkhealth
int32_t cardreader_do_checkhealth(struct s_reader * reader)
{
struct s_client *cl = reader->client;
if (reader_card_inserted(reader)) {
if (reader->card_status == NO_CARD || reader->card_status == UNKNOWN) {
rdr_log(reader, "card detected");
led_status_card_detected();
reader->card_status = CARD_NEED_INIT;
add_job(cl, ACTION_READER_RESET, NULL, 0);
}
} else {
rdr_debug_mask(reader, D_READER, "%s: !reader_card_inserted", __func__);
if (reader->card_status == CARD_INSERTED || reader->card_status == CARD_NEED_INIT) {
rdr_log(reader, "card ejected");
reader_nullcard(reader);
NULLFREE(reader->csystem_data);
if (cl) {
cl->lastemm = 0;
cl->lastecm = 0;
}
led_status_card_ejected();
}
reader->card_status = NO_CARD;
}
rdr_debug_mask(reader, D_READER, "%s: reader->card_status = %d, ret = %d", __func__,
reader->card_status, reader->card_status == CARD_INSERTED);
return reader->card_status == CARD_INSERTED;
}
示例2: ICC_Async_Close
int32_t ICC_Async_Close (struct s_reader *reader)
{
rdr_debug_mask(reader, D_IFD, "Closing device %s", reader->device);
call(reader->crdr.close(reader));
rdr_debug_mask(reader, D_IFD, "Device %s succesfully closed", reader->device);
return OK;
}
示例3: Cool_Init
int32_t Cool_Init (struct s_reader *reader)
{
char *device = reader->device;
int32_t reader_nb = 0;
// this is to stay compatible with older config.
if(strlen(device))
reader_nb=atoi((const char *)device);
if(reader_nb>1) {
// there are only 2 readers in the coolstream : 0 or 1
rdr_log(reader, "Coolstream reader device can only be 0 or 1");
return FALSE;
}
if(!cs_malloc(&reader->spec_dev,sizeof(struct s_coolstream_reader), -1)) return 0;
if (cnxt_smc_open (&specdev()->handle, &reader_nb, NULL, NULL))
return FALSE;
int32_t ret = cnxt_smc_enable_flow_control(specdev()->handle);
coolapi_check_error("cnxt_smc_enable_flow_control", ret);
specdev()->cardbuflen = 0;
if (reader->cool_timeout_init > 0) {
rdr_debug_mask(reader, D_DEVICE, "init timeout set to cool_timeout_init = %i", reader->cool_timeout_init);
specdev()->read_write_transmit_timeout = reader->cool_timeout_init;
} else {
rdr_debug_mask(reader, D_DEVICE, "No init timeout specified - using default init timeout (%i). If you encounter any problems while card init try to use the reader parameter cool_timeout_init = 500",
READ_WRITE_TRANSMIT_TIMEOUT);
specdev()->read_write_transmit_timeout = READ_WRITE_TRANSMIT_TIMEOUT;
}
return OK;
}
示例4: ICC_Async_GetPLL_Divider
static int32_t ICC_Async_GetPLL_Divider (struct s_reader * reader)
{
if(reader->divider != 0) return reader->divider;
if(reader->mhz != 8300) /* Check dreambox is not DM7025 */ {
float divider;
divider = ((float) reader->mhz) / ((float) reader->cardmhz);
reader->divider = (int32_t) divider;
if(divider > reader->divider) reader->divider++; /* to prevent over clocking, ceil (round up) the divider */
rdr_debug_mask(reader, D_DEVICE,"PLL maxmhz = %.2f, wanted cardmhz = %.2f, divider used = %d, actualcardclock=%.2f", (float) reader->mhz/100, (float) reader->cardmhz/100,
reader->divider, (float) reader->mhz/reader->divider/100);
reader->cardmhz = reader->mhz/reader->divider;
}
else /* STB is DM7025 */ {
int32_t i, dm7025_clock_freq[] = {518, 461, 395, 360, 319, 296, 267, 244, 230, 212, 197},
dm7025_PLL_setting[] = {6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}, t_cardmhz = reader->cardmhz;
for(i = 0; i < 11; i++)
if(t_cardmhz >= dm7025_clock_freq[i]) break;
if(i > 10) i = 10;
reader->cardmhz = dm7025_clock_freq[i];
reader->divider = dm7025_PLL_setting[i]; /*Nicer way of codeing is: reader->divider = i + 6;*/
rdr_debug_mask(reader, D_DEVICE,"DM7025 PLL maxmhz = %.2f, wanted cardmhz = %.2f, PLL setting used = %d, actualcardclock=%.2f", (float) reader->mhz/100, (float) t_cardmhz/100,
reader->divider, (float) reader->cardmhz/100);
}
return reader->divider;
}
示例5: pcsc_do_api
static int32_t pcsc_do_api(struct s_reader *pcsc_reader, const uchar *buf, uchar *cta_res, uint16_t *cta_lr, int32_t l)
{
LONG rv;
DWORD dwSendLength, dwRecvLength;
*cta_lr = 0;
if(!l)
{
rdr_log(pcsc_reader, "ERROR: Data length to be send to the pcsc_reader is %d", l);
return ERROR;
}
char tmp[l * 3];
dwRecvLength = CTA_RES_LEN;
struct pcsc_data *crdr_data = pcsc_reader->crdr_data;
if(crdr_data->dwActiveProtocol == SCARD_PROTOCOL_T0)
{
// explanantion as to why we do the test on buf[4] :
// Issuing a command without exchanging data :
//To issue a command to the card that does not involve the exchange of data (either sent or received), the send and receive buffers must be formatted as follows.
//The pbSendBuffer buffer must contain the CLA, INS, P1, and P2 values for the T=0 operation. The P3 value is not sent. (This is to differentiate the header from the case where 256 bytes are expected to be returned.)
//The cbSendLength parameter must be set to four, the size of the T=0 header information (CLA, INS, P1, and P2).
//The pbRecvBuffer will receive the SW1 and SW2 status codes from the operation.
//The pcbRecvLength should be at least two and will be set to two upon return.
if(buf[4])
{ dwSendLength = l; }
else
{ dwSendLength = l - 1; }
rdr_debug_mask(pcsc_reader, D_DEVICE, "sending %lu bytes to PCSC : %s", (unsigned long)dwSendLength, cs_hexdump(1, buf, l, tmp, sizeof(tmp)));
rv = SCardTransmit(crdr_data->hCard, SCARD_PCI_T0, (LPCBYTE) buf, dwSendLength, NULL, (LPBYTE) cta_res, (LPDWORD) &dwRecvLength);
*cta_lr = dwRecvLength;
}
else if(crdr_data->dwActiveProtocol == SCARD_PROTOCOL_T1)
{
dwSendLength = l;
rdr_debug_mask(pcsc_reader, D_DEVICE, "sending %lu bytes to PCSC : %s", (unsigned long)dwSendLength, cs_hexdump(1, buf, l, tmp, sizeof(tmp)));
rv = SCardTransmit(crdr_data->hCard, SCARD_PCI_T1, (LPCBYTE) buf, dwSendLength, NULL, (LPBYTE) cta_res, (LPDWORD) &dwRecvLength);
*cta_lr = dwRecvLength;
}
else
{
rdr_debug_mask(pcsc_reader, D_DEVICE, "PCSC invalid protocol (T=%lu)", (unsigned long)crdr_data->dwActiveProtocol);
return ERROR;
}
rdr_debug_mask(pcsc_reader, D_DEVICE, "received %d bytes from PCSC with rv=%lx : %s", *cta_lr, (unsigned long)rv, cs_hexdump(1, cta_res, *cta_lr, tmp, sizeof(tmp)));
rdr_debug_mask(pcsc_reader, D_DEVICE, "PCSC doapi (%lx ) (T=%d), %d", (unsigned long)rv, (crdr_data->dwActiveProtocol == SCARD_PROTOCOL_T0 ? 0 : 1), *cta_lr);
if(rv == SCARD_S_SUCCESS)
{
return OK;
}
else
{
return ERROR;
}
}
示例6: Cool_Set_Transmit_Timeout
int32_t Cool_Set_Transmit_Timeout(struct s_reader *reader, uint32_t set)
{
//set=0 (init), set=1(after init)
if (set) {
if (reader->cool_timeout_after_init > 0) {
specdev()->read_write_transmit_timeout = reader->cool_timeout_after_init;
rdr_debug_mask(reader, D_DEVICE, "timeout set to cool_timeout_after_init = %i", reader->cool_timeout_after_init);
} else {
if (reader->read_timeout > 50) {
rdr_log(reader, "ATTENTION: The calculated timeout after init value (%i) is greater than 50 which probably leads to a slow card response. We are going to use the reader parameter cool_timeout_after_init = 50.", reader->read_timeout);
rdr_log(reader, "If you encounter any problems try a higher value. If you have no problems try a value below to get a faster card response.");
specdev()->read_write_transmit_timeout = 50;
} else {
rdr_debug_mask(reader, D_DEVICE, "no timeout specified - using calculated timeout after init (%i)", reader->read_timeout);
specdev()->read_write_transmit_timeout = reader->read_timeout;
}
}
} else {
if (reader->cool_timeout_init > 0) {
specdev()->read_write_transmit_timeout = reader->cool_timeout_init;
} else {
specdev()->read_write_transmit_timeout = READ_WRITE_TRANSMIT_TIMEOUT;
}
}
return OK;
}
示例7: IO_Serial_SetParity
int32_t IO_Serial_SetParity (struct s_reader * reader, unsigned char parity)
{
struct termios tio;
int32_t current_parity;
// Get current parity
if (tcgetattr (reader->handle, &tio) != 0){
rdr_log(reader, "ERROR: Could not get current parity, %s (errno=%d %s)", __func__, errno, strerror(errno));
current_parity = 5; // set to unknown (5 is not predefined!)
}
else {
if (((tio.c_cflag) & PARENB) == PARENB)
{
if (((tio.c_cflag) & PARODD) == PARODD)
current_parity = PARITY_ODD;
else
current_parity = PARITY_EVEN;
}
else
{
current_parity = PARITY_NONE;
}
}
if (current_parity != parity)
{
rdr_debug_mask(reader, D_IFD, "Setting parity from %s to %s",
current_parity == PARITY_ODD ? "Odd" :
current_parity == PARITY_NONE ? "None" :
current_parity == PARITY_EVEN ? "Even" : "Unknown",
parity == PARITY_ODD ? "Odd" :
parity == PARITY_NONE ? "None" :
parity == PARITY_EVEN ? "Even" : "Invalid");
// Set the parity
switch (parity)
{
case PARITY_ODD:
tio.c_cflag |= PARENB;
tio.c_cflag |= PARODD;
break;
case PARITY_EVEN:
tio.c_cflag |= PARENB;
tio.c_cflag &= ~PARODD;
break;
case PARITY_NONE:
tio.c_cflag &= ~PARENB;
break;
}
if (IO_Serial_SetProperties (reader, tio)){
rdr_debug_mask(reader, D_IFD, "ERROR: could set parity!");
return ERROR;
}
}
return OK;
}
示例8: ICC_Async_Close
int32_t ICC_Async_Close(struct s_reader *reader)
{
rdr_debug_mask(reader, D_IFD, "Closing device %s", reader->device);
call(reader->crdr.close(reader));
if(reader->typ != R_SC8in1) { NULLFREE(reader->crdr_data); }
rdr_debug_mask(reader, D_IFD, "Device %s succesfully closed", reader->device);
return OK;
}
示例9: IO_Serial_SetBitrate
bool IO_Serial_SetBitrate (struct s_reader * reader, uint32_t bitrate, struct termios * tio)
{
/* Set the bitrate */
#if defined(__linux__)
//FIXME workaround for Smargo until native mode works
if ((reader->mhz == reader->cardmhz) && (reader->smargopatch != 1) && IO_Serial_Bitrate(bitrate) != B0)
#else
if(IO_Serial_Bitrate(bitrate) == B0)
{
rdr_log(reader, "Baudrate %u not supported", bitrate);
return ERROR;
}
else
#endif
{ //no overclocking
cfsetospeed(tio, IO_Serial_Bitrate(bitrate));
cfsetispeed(tio, IO_Serial_Bitrate(bitrate));
rdr_debug_mask(reader, D_DEVICE, "standard baudrate: cardmhz=%d mhz=%d -> effective baudrate %u",
reader->cardmhz, reader->mhz, bitrate);
}
#if defined(__linux__)
else
{ //over or underclocking
/* these structures are only available on linux */
struct serial_struct nuts;
// This makes valgrind happy, because it doesn't know what TIOCGSERIAL does
// Without this there are lots of misleading errors of type:
// "Conditional jump or move depends on uninitialised value(s)"
nuts.baud_base = 0;
nuts.custom_divisor = 0;
ioctl(reader->handle, TIOCGSERIAL, &nuts);
int32_t custom_baud_asked = bitrate * reader->mhz / reader->cardmhz;
nuts.custom_divisor = (nuts.baud_base + (custom_baud_asked/2))/ custom_baud_asked;
int32_t custom_baud_delivered = nuts.baud_base / nuts.custom_divisor;
rdr_debug_mask(reader, D_DEVICE, "custom baudrate: cardmhz=%d mhz=%d custom_baud=%d baud_base=%d divisor=%d -> effective baudrate %d",
reader->cardmhz, reader->mhz, custom_baud_asked, nuts.baud_base, nuts.custom_divisor, custom_baud_delivered);
int32_t baud_diff = custom_baud_delivered - custom_baud_asked;
if (baud_diff < 0)
baud_diff = (-baud_diff);
if (baud_diff > 0.05 * custom_baud_asked) {
rdr_log(reader, "WARNING: your card is asking for custom_baudrate = %i, but your configuration can only deliver custom_baudrate = %i",custom_baud_asked, custom_baud_delivered);
rdr_log(reader, "You are over- or underclocking, try OSCam when running your reader at normal clockspeed as required by your card, and setting mhz and cardmhz parameters accordingly.");
if (nuts.baud_base <= 115200)
rdr_log(reader, "You are probably connecting your reader via a serial port, OSCam has more flexibility switching to custom_baudrates when using an USB->serial converter, preferably based on FTDI chip.");
}
nuts.flags &= ~ASYNC_SPD_MASK;
nuts.flags |= ASYNC_SPD_CUST;
ioctl(reader->handle, TIOCSSERIAL, &nuts);
cfsetospeed(tio, IO_Serial_Bitrate(38400));
cfsetispeed(tio, IO_Serial_Bitrate(38400));
}
#endif
if (reader->typ == R_SC8in1) {
reader->sc8in1_config->current_baudrate = bitrate;
}
return OK;
}
示例10: ICC_Async_Receive
int32_t ICC_Async_Receive(struct s_reader *reader, uint32_t size, unsigned char *data, uint32_t delay, uint32_t timeout)
{
rdr_debug_mask(reader, D_IFD, "Receive size %d bytes, delay %d us, timeout=%d us", size, delay, timeout);
call(reader->crdr.receive(reader, data, size, delay, timeout));
rdr_debug_mask(reader, D_IFD, "Receive succesful");
if(reader->convention == ATR_CONVENTION_INVERSE && reader->crdr.need_inverse == 1)
{ ICC_Async_InvertBuffer(size, data); }
return OK;
}
示例11: IO_Serial_Write
bool IO_Serial_Write (struct s_reader * reader, uint32_t delay, uint32_t timeout, uint32_t size, const unsigned char * data)
{
if (timeout == 0){ // General fix for readers not communicating timeout and delay
if (reader->char_delay != 0) timeout = reader->char_delay; else timeout = 1000000;
rdr_debug_mask(reader, D_DEVICE,"Warning: write timeout 0 changed to %d us", timeout);
}
uint32_t count, to_send, i_w;
unsigned char data_w[512];
to_send = (delay? 1: size); // calculate chars to send at one
rdr_debug_mask(reader, D_DEVICE,"Write timeout %d us, write delay %d us, to send %d char(s), chunksize %d char(s)", timeout, delay, size, to_send);
for (count = 0; count < size; count += to_send)
{
if (count + to_send > size){
to_send = size - count;
}
uint16_t errorcount=0, to_do=to_send;
for (i_w=0; i_w < to_send; i_w++)
data_w [i_w] = data [count + i_w];
rdr_ddump_mask(reader, D_DEVICE, data_w+(to_send-to_do), to_do, "Sending:");
AGAIN:
if (!IO_Serial_WaitToWrite (reader, delay, timeout))
{
while (to_do !=0){
int32_t u = write (reader->handle, data_w+(to_send-to_do), to_do);
if (u < 1) {
if (errno==EINTR) continue; //try again in case of Interrupted system call
if (errno==EAGAIN) goto AGAIN; //EAGAIN needs a select procedure again
errorcount++;
int16_t written = count + to_send - to_do;
if (u != 0) {
rdr_log(reader, "ERROR: %s: Written=%d of %d (errno=%d %s)",
__func__, written , size, errno, strerror(errno));
}
if (errorcount > 10){ //exit if more than 10 errors
return ERROR;
}
}
else {
to_do -= u;
errorcount = 0;
if (reader->crdr.read_written)
reader->written += u; // these readers echo transmitted chars
}
}
}
else
{
rdr_log(reader, "Timeout in IO_Serial_WaitToWrite, delay=%d us, timeout=%d us", delay, timeout);
return ERROR;
}
}
return OK;
}
示例12: ICC_Async_Device_Init
int32_t ICC_Async_Device_Init (struct s_reader *reader)
{
reader->fdmc=-1;
rdr_debug_mask(reader, D_IFD, "Opening device %s", reader->device);
reader->written = 0;
int32_t ret = reader->crdr.reader_init(reader);
if (ret == OK)
rdr_debug_mask(reader, D_IFD, "Device %s succesfully opened", reader->device);
else
rdr_debug_mask(reader, D_IFD, "ERROR: Can't open %s device", reader->device);
return ret;
}
示例13: ICC_Async_Activate
int32_t ICC_Async_Activate(struct s_reader *reader, ATR *atr, uint16_t deprecated)
{
rdr_debug_mask(reader, D_IFD, "Activating card");
reader->current_baudrate = DEFAULT_BAUDRATE;
if(reader->atr[0] != 0 && !reader->ins7e11_fast_reset)
{
rdr_log(reader, "Using ATR from reader config");
ATR_InitFromArray(atr, reader->atr, ATR_MAX_SIZE);
}
else
{
call(reader->crdr.activate(reader, atr));
if(reader->crdr.skip_extra_atr_parsing)
{ return OK; }
}
unsigned char atrarr[ATR_MAX_SIZE];
uint32_t atr_size;
ATR_GetRaw(atr, atrarr, &atr_size);
char tmp[atr_size * 3 + 1];
rdr_log(reader, "ATR: %s", cs_hexdump(1, atrarr, atr_size, tmp, sizeof(tmp)));
memcpy(reader->card_atr, atrarr, atr_size);
reader->card_atr_length = atr_size;
/* Get ICC reader->convention */
if(ATR_GetConvention(atr, &(reader->convention)) != ATR_OK)
{
rdr_log(reader, "ERROR: Could not read reader->convention");
reader->convention = 0;
reader->protocol_type = 0;
return ERROR;
}
reader->protocol_type = ATR_PROTOCOL_TYPE_T0;
// Parse_ATR and InitCard need to be included in lock because they change parity of serial port
if(reader->crdr.lock)
{ reader->crdr.lock(reader); }
int32_t ret = Parse_ATR(reader, atr, deprecated);
if(reader->crdr.unlock)
{ reader->crdr.unlock(reader); }
if(ret)
{ rdr_log(reader, "ERROR: Parse_ATR returned error"); }
if(ret)
{ return ERROR; }
rdr_debug_mask(reader, D_IFD, "Card succesfully activated");
return OK;
}
示例14: reader_do_emm
int32_t reader_do_emm(struct s_reader * reader, EMM_PACKET *ep)
{
int32_t i, rc, ecs;
unsigned char md5tmp[MD5_DIGEST_LENGTH];
struct timeb tps;
struct s_client *cl = reader->client;
if(!cl)
return 0;
cs_ftime(&tps);
MD5(ep->emm, ep->emm[2], md5tmp);
for (i = ecs = 0; i < CS_EMMCACHESIZE; i++) {
if (!memcmp(cl->emmcache[i].emmd5, md5tmp, CS_EMMSTORESIZE)) {
cl->emmcache[i].count++;
if (reader->cachemm) {
if (cl->emmcache[i].count > reader->rewritemm) {
ecs = 2; //skip emm
} else {
ecs = 1; //rewrite emm
}
}
break;
}
}
// Ecs=0 not found in cache
// Ecs=1 found in cache, rewrite emm
// Ecs=2 skip
if ((rc = ecs) < 2) {
if (is_cascading_reader(reader)) {
rdr_debug_mask(reader, D_READER, "network emm reader");
if (reader->ph.c_send_emm) {
rc = reader->ph.c_send_emm(ep);
} else {
rdr_debug_mask(reader, D_READER, "send_emm() support missing");
rc = 0;
}
} else {
rdr_debug_mask(reader, D_READER, "local emm reader");
rc = cardreader_do_emm(reader, ep);
}
if (!ecs)
i = reader_store_emm(ep->type, md5tmp);
}
reader_log_emm(reader, ep, i, rc, &tps);
return rc;
}
示例15: Azbox_Init
static int32_t Azbox_Init(struct s_reader *reader)
{
rdr_debug_mask(reader, D_DEVICE, "openxcas sc: init");
if ((reader->handle = openxcas_get_smartcard_device(0)) < 0) {
rdr_debug_mask(reader, D_DEVICE, "openxcas sc: init failed (%d)", reader->handle);
return 0;
}
rdr_debug_mask(reader, D_DEVICE, "openxcas sc: init succeeded");
return OK;
}