Recent

Author Topic: INPUT - OUTPUT via USB  (Read 6261 times)

oproescu

  • New Member
  • *
  • Posts: 44
INPUT - OUTPUT via USB
« on: February 15, 2019, 09:07:10 am »
I do not know how to make data transfer (input - output) through the USB port. Can someone help me with something concrete?
Thank you for your attention!

Oproescu

MarkMLl

  • Hero Member
  • *****
  • Posts: 4163
Re: INPUT - OUTPUT via USB
« Reply #1 on: February 15, 2019, 10:08:18 am »
I'm afraid that that question cannot be answered without knowing first what operating system you're using and second what kind of device you are talking to. Oh, and confirmation that you're asking the question in the context of FPC/Lazarus would help as well.

If you look at the Wikipedia article on USB you will see that there are multiple device classes: things that look like storage, things that look like keyboards/mice, things that look like MIDI, Chinese devices which are combination weather station, MIDI keyboards and missile launchers, and so on.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

oproescu

  • New Member
  • *
  • Posts: 44
Re: INPUT - OUTPUT via USB
« Reply #2 on: February 15, 2019, 04:10:24 pm »
Many thanks MarkMLI, I will be more precise.
It's Lazarus under Windows 10 (or Windows 7).
I'm interested in how data from files created by different devices (for example, position or incremental position transducers, temperature transducers, etc.) can be received via USB. Or, after the data has been processed by the computer, how can this data be sent to other devices such as execution elements (eg servo valve, regulators, etc.). Data processing in the computer is made by the same application that will need to execute and receive / send data via USB.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4163
Re: INPUT - OUTPUT via USB
« Reply #3 on: February 15, 2019, 05:40:43 pm »
I really can't comment safely about the Windows situation, but if it were Linux I'd be using lsusb and referring to the device description in /sys to find out the device's vid:pid numbers and to see what class the OS recognised it as.

If there wasn't an immediate driver provided by the OS or device manufacturer, I'd feed vid:pid to Google to see what it told me about the manufacturer, and then I'd sniff around Github and Sourceforge to see if anybody knew anything about it: it's very common to find the same identifiers applied to functionally-equivalent peripherals in different enclosures, and fairly common to find the same identifiers applied to completely unrelated peripherals like the weather station + missile launcher + MIDI keyboard I alluded to earlier.

You really do need to research this before anybody else can help. The only extra hints that I can provide at this stage is that it is fairly common for measurement devices to pretend to be serial ports, and in particular it's very common to see projects where the measurement and/or actuators are controlled by something like an Arduino (including derivatives such as the "Blue Pill" and Teensy): the Arduino provides a convenient interface between e.g. a serial bus (I2C, SPI) and USB.

You might find https://hackaday.com/ to be a useful resource but again I need to stress that you need to work out what sort of devices you've got: nobody else can.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

sash

  • Sr. Member
  • ****
  • Posts: 366
Re: INPUT - OUTPUT via USB
« Reply #4 on: February 15, 2019, 06:49:02 pm »
I do not know how to make data transfer (input - output) through the USB port.

One does not simply "make data transfer through the USB port", especially on Windows.
They use APIs dedicated to the OS subsystems, not devices. Generally (without special query) you don't even know if device is attached to USB or PCI buses.
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @ Ubuntu 20.04 XFCE

oproescu

  • New Member
  • *
  • Posts: 44
Re: INPUT - OUTPUT via USB
« Reply #5 on: February 16, 2019, 03:05:25 pm »
I want to develop a building of my own. It contains a peripheral (eg a position transducer, etc.) that sends data to the computer through a USB port, and the computer sends values for the execution element (eg an electroventil, an step by step incremental motor etc.). Everything assisted by an application in Lazarus that manages the entire construction. The peripherals (ie the execution elements or the transducers) are assembled by me from the standard modules so that they are compatible with the proposed objective.
What I do not know right now is how I can access Lazarus USB ports. I managed to call the microphone and speaker ports so I can make a program in Lazarus to send or receive data, but for USB I have no information.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4163
Re: INPUT - OUTPUT via USB
« Reply #6 on: February 16, 2019, 06:28:18 pm »
I've told you what to look for, and that's as much as any of us can do.

You might need to check out Comedi, but I don't know whether that has Windows support.
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

irfanbagus

  • Jr. Member
  • **
  • Posts: 60
Re: INPUT - OUTPUT via USB
« Reply #7 on: February 16, 2019, 08:00:07 pm »
... but for USB I have no information.
start with reading how usb port working.

avra

  • Hero Member
  • *****
  • Posts: 2331
    • Additional info
Re: INPUT - OUTPUT via USB
« Reply #8 on: February 16, 2019, 11:28:35 pm »
It contains a peripheral (eg a position transducer, etc.) that sends data to the computer through a USB port
You need to know the basics first... It is not enough to say that device sends data to computer through USB. You must look at the datasheet of the device and find out more details. Is it serial communication over USB, or it has some proprietary driver? Is it a commercial device or some customizable Arduino like device with open source firmware? If serial over USB then what are connection parameters, and what is the protocol used? Is that protocol supported with something like PascalSCADA? Is it some common protocol for which already exists a freepascal lib? If not then is it more meaningful to write support communication lib from scratch, or simply buy a different device for which there is already a freepascal communication lib?
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

oproescu

  • New Member
  • *
  • Posts: 44
Re: INPUT - OUTPUT via USB
« Reply #9 on: February 17, 2019, 08:50:17 am »
I found out enough information to consider this topic closed. Thank you for your interest!

McClane

  • New Member
  • *
  • Posts: 44
Re: INPUT - OUTPUT via USB
« Reply #10 on: January 28, 2022, 04:14:36 pm »
Hi oproescu, I want to learn to turn my cam on. I have a laptop with a cam on it and I'm a linux user.
Can you teach me how you managed to communicate with your mic?
Any help would be appreciated, thanks and have you all a nice day.

mischi

  • Full Member
  • ***
  • Posts: 168
Re: INPUT - OUTPUT via USB
« Reply #11 on: January 28, 2022, 04:33:01 pm »
I would have a look in to gphoto and libgphoto. I think they offer, what you need. If not, look for other libraries, which control cams.

McClane

  • New Member
  • *
  • Posts: 44
Re: INPUT - OUTPUT via USB
« Reply #12 on: January 31, 2022, 06:01:29 am »
Hi Mischi, thank you for replying this post since I know it's old.
I wonder if it would be possible to access a USB port without external libraries, like using ports unit. Would it be possible?
Have a nice day.

MarkMLl

  • Hero Member
  • *****
  • Posts: 4163
Re: INPUT - OUTPUT via USB
« Reply #13 on: January 31, 2022, 09:23:02 am »
Hi Mischi, thank you for replying this post since I know it's old.
I wonder if it would be possible to access a USB port without external libraries, like using ports unit. Would it be possible?
Have a nice day.

Not unless you've got ten years to spare.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

ccrause

  • Hero Member
  • *****
  • Posts: 568
Re: INPUT - OUTPUT via USB
« Reply #14 on: January 31, 2022, 10:35:02 am »
Hi Mischi, thank you for replying this post since I know it's old.
I wonder if it would be possible to access a USB port without external libraries, like using ports unit. Would it be possible?
Have a nice day.

Not unless you've got ten years to spare.

MarkMLl
For HID you can try FPC-USB-HID, it has no external dependencies.

 

TinyPortal © 2005-2018