LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 03-05-2021, 07:13 AM   #1
DJTJ
LQ Newbie
 
Registered: Mar 2021
Posts: 2

Rep: Reputation: Disabled
Trouble in C# environment with opening stream on usb com-port device: "Inappropriate ioctl for device"


Hello everybody,
I am trying to establish a "communication-stream" with a device that is connected to my computer via a USB cable. The driver for the device seems to work, as I can establish this stream via a molex uart cable. But this connection also has to work for a microusb(plugged into device) to USB cable.
Now, what does "communication-stream" mean?
I am working in a C# development environment on Visual Code IDE. In the code I access the port name list via Directory.GetFiles("/dev/", "tty*");
Then I initialize a SerialPort with: stream = new SerialPort("portName",<baud rate>, Parity.None, <databits>, StopBits.None).
After that I want to open the stream, so that I can receive ACK's and send commands from and to the device with: stream.Open();

With the uart cable this works fine and I can work with the device. But when using the USB cable, an exception is thrown, stating that the IOCTL is inappropriate for the device.

What exactly is the ioctl (input output control)? Why can it be "inappropriate" for my device, when using a specific cable (or with it a different port?)?

Is there a solution to my problem?

No knowledge about the device is needed here I think, as the ioctl seems to be a Linux-specific feature.

I would be really happy to receive an answer to my questions, thanks in advance
 
Old 03-05-2021, 08:34 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
1. c# is probably not the best way on linux
2. by the way which os/compiler/environment is it?
3. https://man7.org/linux/man-pages/man2/ioctl.2.html
4. I guess you need to find the correct device name (/dev/whatever), the problem (IOCTL is inappropriate for the device) is caused by using a non-existent or different device.
 
Old 03-09-2021, 06:53 AM   #3
DJTJ
LQ Newbie
 
Registered: Mar 2021
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hello pan64,
Thanks for your reply!
I am working on an ubuntu 18 Laptop.
Sadly I am sort of constrained to use C# because the project is developed with the unity3D game engine which only allows scripting in C#.
The device name actually should be correct (dev/ttyUSB0) since it works with using the other cable type (uart) and using any other name will result in an error(no such file or directory)
 
Old 03-09-2021, 07:18 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,041

Rep: Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348Reputation: 7348
you can use the commands lsusb and lspci to check what is connected (and which usb port is used).
probably the "other cable type" will use another [virtual] usb port.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"stty: standard input: Inappropriate ioctl for device" when running program eldiener Programming 3 05-03-2017 10:30 PM
cannot open port "default": Inappropriate ioctl for device hitsware Linux - Newbie 3 07-26-2012 08:47 AM
Weird Perl error with "Inappropriate ioctl for device" bnutting Programming 9 03-12-2012 07:25 AM
"Inappropriate ioctl for device" on loopback after rebuild mk27 Linux - Kernel 2 12-02-2009 06:11 PM
chat and "inappropriate ioctl for device" MattFunke Linux - Software 3 01-29-2007 10:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 01:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration