当前位置: 首页>>代码示例>>C++>>正文


C++ pabort函数代码示例

本文整理汇总了C++中pabort函数的典型用法代码示例。如果您正苦于以下问题:C++ pabort函数的具体用法?C++ pabort怎么用?C++ pabort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pabort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hw_pinMode

void SPIClass::begin() {
    int ret =0;
    int max_speed = 0, default_mode=0;
    int mode;
 
    hw_pinMode(SPI_CS, IO_SPI_FUNC); //CS
    hw_pinMode(SPI_MOSI, IO_SPI_FUNC); //MOSI
    hw_pinMode(SPI_MISO, IO_SPI_FUNC); //MISO
    hw_pinMode(SPI_CLK, IO_SPI_FUNC); //CLK
		
    if (!_fd)
   		_fd = open(spi_name, O_RDWR);
    if (_fd < 0)
        pabort("can't open device");
	
	_speed = 500000;
    ret = ioctl(_fd, SPI_IOC_RD_MODE, &default_mode);
    if (ret == -1)
        pabort("can't get spi mode");
    mode = default_mode;

    ret = ioctl(_fd, SPI_IOC_RD_MAX_SPEED_HZ, &max_speed);
    if (ret == -1)
        pabort("can't get max speed hz");
    _speed = max_speed;

    printf("spi mode: 0x%x\n", mode);
    printf("bits per word: %d\n", _bits_per_word);
    printf("max speed: %d Hz (%d KHz)\n", _speed, _speed/1000);
}
开发者ID:IB4650,项目名称:jarduino,代码行数:30,代码来源:SPI.cpp

示例2: transfer_file

static void transfer_file(int fd, char *filename)
{
    ssize_t bytes;
    struct stat sb;
    int tx_fd;
    uint8_t *tx;
    uint8_t *rx;

    if (stat(filename, &sb) == -1)
        pabort("can't stat input file");

    tx_fd = open(filename, O_RDONLY);
    if (tx_fd < 0)
        pabort("can't open input file");

    tx = malloc(sb.st_size);
    if (!tx)
        pabort("can't allocate tx buffer");

    rx = malloc(sb.st_size);
    if (!rx)
        pabort("can't allocate rx buffer");

    bytes = read(tx_fd, tx, sb.st_size);
    if (bytes != sb.st_size)
        pabort("failed to read input file");

    transfer(fd, tx, rx, sb.st_size);
    free(rx);
    free(tx);
    close(tx_fd);
}
开发者ID:vcaputo,项目名称:linux,代码行数:32,代码来源:spidev_test.c

示例3: transfer_buf

static void transfer_buf(int fd, int len)
{
	uint8_t *tx;
	uint8_t *rx;
	int i;

	tx = malloc(len);
	if (!tx)
		pabort("can't allocate tx buffer");
	for (i = 0; i < len; i++)
		tx[i] = random();

	rx = malloc(len);
	if (!rx)
		pabort("can't allocate rx buffer");

	transfer(fd, tx, rx, len);

	_write_count += len;
	_read_count += len;

	if (mode & SPI_LOOP) {
		if (memcmp(tx, rx, len)) {
			fprintf(stderr, "transfer error !\n");
			hex_dump(tx, len, 32, "TX");
			hex_dump(rx, len, 32, "RX");
			exit(1);
		}
	}

	free(rx);
	free(tx);
}
开发者ID:AlexShiLucky,项目名称:linux,代码行数:33,代码来源:spidev_test.c

示例4: directWrite

static PyObject* directWrite(PyObject* self, PyObject* arg)
{
	PyObject* transferTuple;
	unsigned int offset, returnVal ;

	if(!PyArg_ParseTuple(arg, "lO", &offset, &transferTuple))		
		return NULL;					

	if(!PyTuple_Check(transferTuple))			
		pabort("Only accepts a single tuple as an argument\n");


	uint32_t tupleSize = PyTuple_Size(transferTuple);
	uint8_t tx[tupleSize];
	PyObject* tempItem;
	uint32_t i=0;
	while(i < tupleSize)
	{
		tempItem = PyTuple_GetItem(transferTuple, i);		//
		if(!PyInt_Check(tempItem))
		{
			pabort("non-integer contained in tuple\n");
		}
		tx[i] = (uint8_t)PyInt_AsSsize_t(tempItem);
		i++;

	}
	returnVal = direct_write(offset, tx, tupleSize);
	return Py_BuildValue("l", returnVal) ;
}
开发者ID:andygikling,项目名称:logi-tools,代码行数:30,代码来源:mark1-rpi.c

示例5: open_spidev

int open_spidev(const char *device, uint8_t mode, uint32_t speed)
{
   int spifd, ret;

   spifd = open(device, O_RDWR);
   if (spifd < 0)
      pabort("can't open device");

   /*
    * spi mode
    */
   ret = ioctl(spifd, SPI_IOC_WR_MODE, &mode);
   if (ret == -1)
      pabort("can't set spi mode");

   ret = ioctl(spifd, SPI_IOC_RD_MODE, &mode);
   if (ret == -1)
      pabort("can't get spi mode");

   /*
    * max speed hz
    */
   ret = ioctl(spifd, SPI_IOC_WR_MAX_SPEED_HZ, &speed);
   if (ret == -1)
      pabort("can't set max speed hz");

   ret = ioctl(spifd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
   if (ret == -1)
      pabort("can't get max speed hz");

   return spifd;
}
开发者ID:kkadatoka,项目名称:rpi-dev,代码行数:32,代码来源:readid.c

示例6: transfer

static PyObject* transfer(PyObject* self, PyObject* arg)
{
	PyObject* transferTuple;

	if(!PyArg_ParseTuple(arg, "O", &transferTuple))		// "O" - Gets non-NULL borrowed reference to Python argument.
		return NULL;					// As far as I can tell, it's mostly just copying arg[0] into transferTuple
								// and making sure at least one arg has been passed (I think)

	if(!PyTuple_Check(transferTuple))			// The only argument we support is a single tuple.
		pabort("Only accepts a single tuple as an argument\n");


	uint32_t tupleSize = PyTuple_Size(transferTuple);

	uint8_t tx[tupleSize];
	uint8_t rx[tupleSize];
	PyObject* tempItem;

	uint16_t i=0;

	while(i < tupleSize)
	{
		tempItem = PyTuple_GetItem(transferTuple, i);		//
		if(!PyInt_Check(tempItem))
		{
			pabort("non-integer contained in tuple\n");
		}
		tx[i] = (uint8_t)PyInt_AsSsize_t(tempItem);

		i++;

	}

	struct spi_ioc_transfer tr = {
		.tx_buf = (unsigned long)tx,
		.rx_buf = (unsigned long)rx,
		.len = tupleSize,
		.delay_usecs = delay,
		.speed_hz = speed,
		.bits_per_word = bits,
                .cs_change = 1,
	};

	ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
	if (ret < 1)
		pabort("can't send spi message");

	transferTuple = PyTuple_New(tupleSize);
	for(i=0;i<tupleSize;i++)
		PyTuple_SetItem(transferTuple, i, Py_BuildValue("i",rx[i]));

	return transferTuple;
}


static PyObject* closeSPI(PyObject* self,PyObject* args)
{
	close(fd);
	Py_RETURN_NONE;
}
开发者ID:DomAmato,项目名称:Laser_Engraver,代码行数:60,代码来源:spi.c

示例7: snowleo_spi_custom_read

/**
 * @brief  spi read operation function.
 *
 * @param[in]  fd                 spi file descriptor
 * @param[in]  reg                spi slave register address to be read
 * @param[out] value              read back data
 * @retval                        void
 *
 */
void snowleo_spi_custom_read(int fd, uint8_t *reg, uint8_t *data, uint8_t data_size)
{

	int ret;
#if 0
	struct spi_ioc_transfer tr[2];
	memset(tr, 0, sizeof(tr));
	tr[0].tx_buf = (unsigned long)reg;
	tr[0].len = data_size;

	tr[1].rx_buf = (unsigned long)data;
	tr[1].len = data_size;

	ret = ioctl(fd, SPI_IOC_MESSAGE(2), &tr);
	if (ret < 1)
		pabort("can't send spi message");
#else
	struct spi_ioc_transfer tr1[2];
	memset(tr1, 0, sizeof(tr1));

	int i = 0;
	for(i = 0; i< data_size; i++){
		tr1[0].tx_buf = (unsigned long)&reg[i];
		tr1[0].len = 1;
		tr1[1].rx_buf = (unsigned long)&data[i];
		tr1[1].len = 1;
		ret = ioctl(fd, SPI_IOC_MESSAGE(2), tr1);
		if (ret < 1)
			pabort("can't send spi message");

		//printf("reg[0x%x] = 0x%x\n", reg[i], data[i]);
	}
#endif
}
开发者ID:atommota,项目名称:SNOWLeo-SDR,代码行数:43,代码来源:snowleo_spi_ops.c

示例8: if

char SPIClass::transfer(char val, int transferMode)
{
    int ret=0;
    char tx = val;
    char rx = 0;
	unsigned short delay_usecs = 0;

#ifndef SPI_FULL_DUPLEX
    struct spi_ioc_transfer tr[2]={0};

    if (transferMode == SPI_CONTINUE) 
	   delay_usecs = 0;
	else if (transferMode == SPI_LAST)  
	   delay_usecs = 0xAA55;	

	memset(tr, 0x0, sizeof(tr));
	tr[0].tx_buf = (unsigned long)&tx;
	tr[0].len = 1;
	tr[0].speed_hz = _speed;
	tr[0].bits_per_word = _bits_per_word;
	tr[0].delay_usecs = delay_usecs;
	tr[1].rx_buf = (unsigned long)&rx;
	tr[1].len = 1;
	tr[1].speed_hz = _speed;
	tr[1].bits_per_word = _bits_per_word;
	tr[1].delay_usecs = delay_usecs;

    ret = ioctl(_fd, SPI_IOC_MESSAGE(2), tr);
    if (ret < 1)
        pabort("can't send spi message");
#else
    struct spi_ioc_transfer tr;

    if (transferMode == SPI_CONTINUE) 
	   delay_usecs = 0;
	else if (transferMode == SPI_LAST)  
	   delay_usecs = 0xAA55;	

	memset(&tr, 0x0, sizeof(spi_ioc_transfer));
	tr.tx_buf = (unsigned long)&tx;
	tr.rx_buf = (unsigned long)&rx;
	tr.len = 1;
	tr.speed_hz = _speed;
	tr.bits_per_word = _bits_per_word;
	tr.delay_usecs = delay_usecs;

    ret = ioctl(_fd, SPI_IOC_MESSAGE(1), &tr);
    if (ret < 1)
        pabort("can't send spi message");
#endif

    //printf("rx = %.2X \r\n", rx);

    return rx;

}
开发者ID:IB4650,项目名称:jarduino,代码行数:56,代码来源:SPI.cpp

示例9: main

int main(int argc, char *argv[])
{
	int ret = 0,cnt =0;
	int fd,fds,i,diff =0;
	unsigned int dist,prevdist = 0,prev_direction;
        struct sigaction act;
	fd = open(display, O_RDWR);
	if (fd < 0)
		pabort("can't open device");
	printf("\n initialising....:");
	ioctl(fd, SPI_LED_INITIALISE, 0);
	transfer(fd);
	fds = open(sensor, O_RDWR);
	if (fds < 0)
		pabort("can't open sensor");

        memset (&act, '\0', sizeof(act));
        act.sa_sigaction = &terminatehdl;
        act.sa_flags = SA_SIGINFO;
        if (sigaction(SIGINT, &act,NULL) < 0) {
                perror ("sigaction");
                return 1;
        }

	while((!terminate)&&(cnt < 120)){	
	  dist = read(fds,NULL,0);
	  write(fds,NULL,0);
	  printf("\ndistance is %lu \n",dist);
	  diff  = dist - prevdist;
	  if(diff<0)
	  {
	    diff = prevdist - dist;
	  }
	  if(dist < 40)
	  {
	      move_left(fd);
          }
	  else 
	  {
	      move_right(fd);
          }
	  prevdist = dist;
	  cnt++;
	}
	write(fd,NULL,0);
	/* time to displat some patterns */
	transfer_moves(fd);
	anime(fd);	
	write(fd,NULL,0);
	usleep(100000);
	close(fd);
	close(fds);
	return 0;
}
开发者ID:premswar,项目名称:kernel_programs,代码行数:54,代码来源:test_drivers.c

示例10: transfer

static void transfer(int fd)
{
	int ret;
	ret = ioctl(fd, SPI_IOC_MESSAGE(ntransfers), spi_xfrs);
	if (ret < 1)
		pabort("can't send spi message");
}
开发者ID:KnCMiner,项目名称:spi-test,代码行数:7,代码来源:spi-test.c

示例11: transfer

static void transfer(int fd, uint8_t *tx, uint8_t *rx, int len)
{
   int ret;
   struct spi_ioc_transfer tr = {
      .len = len,
   };

   printf("\n%s(len=%d):\n", __func__);

   if (tx) {
      tr.tx_buf = (unsigned long)tx;
      printf("  TX: ");
      print_hex(tx, len);
   }
   if (rx)
      tr.rx_buf = (unsigned long)rx;

   ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
   if (ret < 1)
      pabort("can't send spi message");

   if (rx) {
      printf("  RX: ");
      print_hex(rx, len);
   }
}
开发者ID:kkadatoka,项目名称:rpi-dev,代码行数:26,代码来源:readid.c

示例12: pLog

void P_CCONV pLog(PLogVerbosityEnum verbosity, 
    PLogChannelEnum channel,
    const pchar *file, 
    puint32 line, 
    const pchar *format, 
    ...)
{
    // The global verbosity value controls which kinds of log can be 
    // printed.
    if (verbosity < g_logVerbosity)
    {
        return ;
    }

    static const pchar *verbosityText[] = 
    {
        "(debug)",
        "(info)",
        "(warning)",
        "(error)",
        "(fatal)",
    };

    va_list arguments;

    va_start(arguments, format);

    if (pstrlen(format) > 200)
    {
        pchar message[1024];
        puint32 nchars = psprintf(message, 1024, 
                "(warning)%s:%d,log buffer for formatting data is too small.",
                __FILE__, __LINE__);
        pLogOutput(P_LOG_CHANNEL2, message, nchars);
    }
    else
    {
        pchar msg[3000]; 
        puint32 nchars;
        if (verbosity == P_LOG_ERROR || verbosity == P_LOG_WARNING)
        {
            pchar fmt[256];
            psprintf(fmt, 256, "%s%s:%d,%s", 
                verbosityText[verbosity], file, line, format);
            nchars = pvsprintf(msg, 3000, fmt, arguments);
        }
        else 
        {
            nchars = pvsprintf(msg, 3000, format, arguments);
        }

        pLogOutput(channel, msg, nchars);
    }

    if (verbosity == P_LOG_FATAL)
    {
        // FIXME: make it more polite
        pabort();
    }
}
开发者ID:Freedom000,项目名称:FutureInterface,代码行数:60,代码来源:plog.cpp

示例13: spi_close

void spi_close(spi_context* spi)
{
  if(close(spi->fd) < 0) {
    pabort("can't close SPI device");
  }
  delete spi;
}
开发者ID:wassup-,项目名称:embedded,代码行数:7,代码来源:spi.cpp

示例14: transfer

static void transfer(int fd)
{
	int ret,i,k;
	uint8_t tr[160];
	uint8_t tx0[] = {
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
        };/* Digit 1  */
	uint8_t tx1[] = {
        0x19,0xFB,0xEC,0x08,0x08,0x0F,0x09,0x10
        };/* Digit 1  */
	uint8_t tx2[] = {
        0x18,0xFF,0xE9,0x08,0x0B,0x0E,0x08,0x04
        };/* Digit 1  */
	uint8_t tx3[] = {
        0x10,0x09,0x0f,0x08,0x08,0xEC,0xFB,0x19
        };/* Digit 1  */
	uint8_t tx4[] = {
        0x04,0x08,0x0E,0x0B,0x08,0xE9,0xFF,0x18
        };/* Digit 1  */
	memset(tr,0,80);
	memcpy(tr,tx0,8);
	memcpy((tr+8),tx1,8);
	memcpy((tr+16),tx2,8);
	memcpy((tr+24),tx3,8);
	memcpy((tr+32),tx4,8);
	ret = ioctl(fd, SPI_LED_TX_PATTERN, &tr);
	if (ret < -1)
		pabort("can't send spi message");
        sleep(1);
}
开发者ID:premswar,项目名称:kernel_programs,代码行数:30,代码来源:test_drivers.c

示例15: transfer

static void transfer(int fd)
{
	int ret;
	uint8_t tx[] = {
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0x40, 0x00, 0x00, 0x00, 0x00, 0x95,
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
		0xDE, 0xAD, 0xBE, 0xEF, 0xBA, 0xAD,
		0xF0, 0x0D,
	};
	uint8_t rx[ARRAY_SIZE(tx)] = {0, };
	struct spi_ioc_transfer tr;
	tr.tx_buf = (unsigned long)tx;
	tr.rx_buf = (unsigned long)rx;
	tr.len = ARRAY_SIZE(tx);
	tr.interbyte_usecs = 10;
	tr.delay_usecs = delay;
	tr.speed_hz = speed;
	tr.bits_per_word = bits;

	ret = ioctl(fd, SPI_IOC_MESSAGE(1), &tr);
	if (ret < 1)
		pabort("can't send spi message");

	for (ret = 0; ret < ARRAY_SIZE(tx); ret++) {
		if (!(ret % 6))
			puts("");
		printf("%.2X ", rx[ret]);
	}
	puts("");
}
开发者ID:AlexeyKuzunov,项目名称:librf24-sunxi,代码行数:33,代码来源:spidev_test.c


注:本文中的pabort函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。