ioctl

How can ejecting an audio CD by using cdaudio's cd_eject () method produce errno #5?

 ̄綄美尐妖づ 提交于 2019-12-08 02:14:49
问题 I'm trying to playback an audio CD from my app by using the cdaudio library + a USB DVD drive attached to a Raspi 3B. Trying to eject the CD after playback always makes me end up with errno #5. This is my code: void sound::Eject () { struct disc_status cd_stat; if (sound::current_sound_source == CD) { sound::Stop (); cd_poll (sound::cd_drive_handler, &cd_stat); if (sound::is_cd_stopped && cd_stat.status_present == 1) { if ((cd_eject (sound::cd_drive_handler)) < 0) cout << "Ejecting CD failed!

Getting essid via ioctl in ruby

China☆狼群 提交于 2019-12-07 15:22:30
问题 To avoid relying on the wireless tools I want to get the essid directly from the device with ioctl, in C this wouldn't be a problem, but in Ruby it's quite different. The problem is following struct from wireless.h that is used as input/reply of ioctl: struct iw_point { void __user *pointer; /* Pointer to the data (in user space) */ __u16 length; /* number of fields or size in bytes */ __u16 flags; /* Optional params */ }; The pointer part must be a valid address of a memory area, followed by

SPI_IOC_MESSAGE(N) macro giving me fits

。_饼干妹妹 提交于 2019-12-07 11:43:18
问题 I'm having trouble getting a SPI program I'm working on to behave correctly and it seems to be some issue with the SPI_IOC_MESSAGE(N) macro. Here's sample code that DOESN'T work (ioctl returns EINVAL (22) ): std::vector<spi_ioc_transfer> tr; <code that fills tr with 1+ transfers> // Hand the transmission(s) off to the SPI driver if (tr.size() > 0) { int ret = ioctl(fd, SPI_IOC_MESSAGE(tr.size()), tr.data()); if (ret < 1) { int err = errno; } } My test code right now is creating a vector of

Using “extern C” on non function call related declarations

家住魔仙堡 提交于 2019-12-07 05:23:56
问题 I know questions regarding extern "C" have been asked before but I am getting mixed signals and would like it if someone could point me to what the best practice is in the scenario below. I have written a driver for Linux and have several struct defined as well as some _IO , _IOR , and _IOW definitions for ioctl(...) calls. None of my structures contain any functions, below is an example struct , enum and ioctl that I use: #ifdef __cplusplus extern "C" { #endif enum Alignment { Left = 0,

Where are ioctl parameters (such as 0x1268 / BLKSSZGET) actually specified?

安稳与你 提交于 2019-12-07 02:47:08
问题 This question was migrated from Unix & Linux Stack Exchange because it can be answered on Stack Overflow. Migrated 6 years ago . I am looking for a definitive specification describing the expected arguments and behavior of ioctl 0x1268 (BLKSSZGET). This number is declared in many places (none of which contain a definitive reference source), such as linux/fs.h , but I can find no specification for it. Surely, somebody at some point in the past decided that 0x1268 would get the physical sector

How does iwlist() command scans the wireless networks?

不打扰是莪最后的温柔 提交于 2019-12-07 02:17:14
问题 I want to know how iwlist command scans the wireless networks available, in linux. I read its source code and there was an ioctl call using SIOCSIWSCAN to trigger the scan and SIOCGIWSCAN to get the scan results. But how the beacon frames are captured and analyzed by these system calls? 回答1: iwlist(8) and the other wireless tools provide a common front end to different wireless device drivers that support Linux Wireless Extensions (WEXT). Each driver will register handlers with WEXT that

How can ejecting an audio CD by using cdaudio's cd_eject () method produce errno #5?

泪湿孤枕 提交于 2019-12-06 06:51:32
I'm trying to playback an audio CD from my app by using the cdaudio library + a USB DVD drive attached to a Raspi 3B. Trying to eject the CD after playback always makes me end up with errno #5. This is my code: void sound::Eject () { struct disc_status cd_stat; if (sound::current_sound_source == CD) { sound::Stop (); cd_poll (sound::cd_drive_handler, &cd_stat); if (sound::is_cd_stopped && cd_stat.status_present == 1) { if ((cd_eject (sound::cd_drive_handler)) < 0) cout << "Ejecting CD failed! Error: " << strerror (errno) << endl; } } } This is the output I get: ioctl returned -1 Ejecting CD

Getting essid via ioctl in ruby

五迷三道 提交于 2019-12-06 03:44:01
To avoid relying on the wireless tools I want to get the essid directly from the device with ioctl, in C this wouldn't be a problem, but in Ruby it's quite different. The problem is following struct from wireless.h that is used as input/reply of ioctl: struct iw_point { void __user *pointer; /* Pointer to the data (in user space) */ __u16 length; /* number of fields or size in bytes */ __u16 flags; /* Optional params */ }; The pointer part must be a valid address of a memory area, followed by the length in bytes, followed by a flag field. I tried with Array#pack and the bit-struct gem, but

Get Terminal width Haskell

时光毁灭记忆、已成空白 提交于 2019-12-05 22:00:17
问题 How to get the width of the terminal in Haskell? Things I tried System.Posix.IOCtl (could not figure out how to get it to work) This only has to work unix. Thanks 回答1: If you don't want a dependency on ncurses, here's a wrapper of the appropriate ioctl() request using the FFI, based on the accepted answer of Getting terminal width in C? TermSize.hsc {-# LANGUAGE ForeignFunctionInterface #-} module TermSize (getTermSize) where import Foreign import Foreign.C.Error import Foreign.C.Types

Add route programmatically in C++ using ioctl

≯℡__Kan透↙ 提交于 2019-12-05 19:29:21
I've written simple C++ function, that adds new route: void addRoute() { int fd = socket( PF_INET, SOCK_DGRAM, IPPROTO_IP ); struct rtentry route; memset( &route, 0, sizeof( route ) ); struct sockaddr_in *addr = (struct sockaddr_in *)&route.rt_gateway; addr->sin_family = AF_INET; addr->sin_addr.s_addr = inet_addr( "192.168.20.1" ); addr = (struct sockaddr_in*) &route.rt_dst; addr->sin_family = AF_INET; addr->sin_addr.s_addr = inet_addr( "10.0.0.50" ); addr = (struct sockaddr_in*) &route.rt_genmask; addr->sin_family = AF_INET; addr->sin_addr.s_addr = INADDR_ANY; route.rt_flags = RTF_UP | RTF