I'm using an FTDI USB-to-Serial converter on linux. I'm writing an application that implements the standard functionality of changing settings like baud rate, etc... The only thing that I'm not sure how to get is the buffer size, e.g. if the user wants to know.
For example in the javax.comm SerialPort API there's a method getInputBufferSize(), so I thought there must be a way to check this on the device being used. So if I'm using a USB-to-Serial converter, is it possible to query it for the buffer size? I checked the termios documentation and cannot see such a setting.
Any suggestions on this please?
Related
i am trying to find an equivalent function on ESP-IDF that will be like Stream() of arduino ,
what i am trying to do is to make an MSP function to communicate with the MSP protocol with the ESPs UART, i am using ESP-IDF and Free-Rtos in an Ubuntu environment and cmake to built
https://www.arduino.cc/reference/en/language/functions/communication/stream/
https://github.com/yajo10/MSP-Arduino/blob/master/MSP.cpp
i tryied to use std::ostringstream* but obviously doesnt make the same job
ostringstream is a specialised ostream where the "device" is a memory buffer. Stream is an unspecialised base class for a number of device sub-classes, and it is bi-directional. The standard library equivalent given a suitable stream I/O driver would be std::istream and std::ostream for input and output respectively, each opened on the specific device. In most cases you would use the derived std::ifstream and std::ofstream class s and open the device as a "file stream".
If you require an identical interface in order to use the code unmodified, then implementing Stream as a wrapper around iostream is feasible.
I want to develop a serial driver using a driver kit framework.I am trying to override IOUserserial class methods.But i don't know how to get the size of buffer to be sent to USB layer using TXDataAvailable() and RXDataAvailable() functions? Any reference code will be helpful.
I'm interested in which fingerprint scanner to use in a project with arduino or raspberry pi. This scanner MUST ONLY take the picture of the fingerprint and not to process neither validate the fingerprint because all of this will be done in a computer.
You can try an R305 module. It is one of the more popular modules with communication over UART. Adafruit has an existing library though it does not cover image download. However, there's substantial documentation that contains all the commands including the command for extracting the images you need. An image is usually a sort of compressed 256x288 grayscale BMP and is typically 37kB in size. You'll need to extrapolate to get the complete 74kB image. You should keep in mind that the maximum baud rate is 115200 or 11.5kB/s so it will take about 4 seconds to download an image before you can begin processing it. An Arduino would be unreliable at that baud rate too.
Another module that is completely compatible with the R305 is the FPM10 module; all the commands are the same and they are easily interchangeable. Here's a tutorial that can help.
I have a project with a Arduino Uno where I need to store a char** that is too big for EPROM.
I am currently trying to do it with serial but I could also use a AVRISP programmer if needed (Not preferable)
So far I have looked into the avr/boot.h API but I am not really sure how to use it properly or if it is even the correct way to do it.
The arduino (specifically atmel 328 versions) only allow you to write to flash memory when the bootloader allows it.
The standard bootloader allows you to write to flash when a new program is being installed, but does not allow runtime programs to write to flash.
Solution: Install a bootloader that does allow you to run functions that enable you to write to flash.
Here is a bootloader (featured on hackaday) for an arduino that allows you to write to flash memory during runtime http://majek.mamy.to/en/writing-to-internal-flash-on-arduino/
Here is the hackaday post on the subject
https://hackaday.com/2015/07/03/arduinos-and-other-avrs-write-to-own-flash/
From the ATmega328P datasheet, "Boot Loader Support" section, "Application and Boot Loader Flash Sections" subsection, "Application Section" subsubsection:
... the SPM instruction is disabled when executed from the Application section.
Therefore there is no way to write to flash from the running program. Use an external memory device if you need to store more data than fits on-board.
I don't believe that's correct. The 328p does have the ability to control what some instructions about where they are allowed to access. I didn't see anywhere that this wasn't possible and in some configurations it (328p) can write flash under it's own control.
I searched the data sheet for 'SPM instruction is disabled' and hit only on the ATmega 48a/48pa. Having confused myself many times with that datasheet reading about the wrong controller. This didn't ring a bell.
Copied directly from the datasheet (660 pages):
"The ATmega 48A/48PA has no separate Boot Loader section, and the SPM instruction is enabled for the whole Flash if the SELFPRGEN fuse is programmed (“0”). Otherwise the SPM instruction is disabled."
The 328p has 'Lock Bit Byte' sets all of these controls, generally speaking.
These also control what access they have.
I would think you'd want to put it into eeprom (which IS different)...
Jack
I have an Arduino-based device which connects through USB.
I'd like to detect it from my Qt 4 application, using QExtSerialPort (or whatever necessary), when it's plugged in.
If this weren't possible, I thought I could somehow get a list of the system's port names and just try all of them in search for my Arduino (where I'd implement some kind of handshaking procedure for it to detect it correctly). My concern in this approach is that I'm not sure if a device (for example, printer) would get damaged if I send some kind of handshaking ack at a different baud rate.
So, I don't really know where to start for any of them. Which would be the best approach? How would I implement it?
I believe you can find list of serial ports on Windows by looking into
HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM
registry key
Each serial port on a UNIX system has one or more device files (files in the /dev directory) associated with it:
System Port 1 Port 2
IRIX® /dev/ttyf1 /dev/ttyf2
HP-UX /dev/tty1p0 /dev/tty2p0
Solaris®/SunOS® /dev/ttya /dev/ttyb
Linux® /dev/ttyS0 /dev/ttyS1
Digital UNIX® /dev/tty01 /dev/tty02
more details on serial programing on POSIX systems here
Since your device is USB, your UART port will be emulated by some kind of conversor in his hardware. So first you must understand what driver is being used on your system.
The most common SERIAL->USB conversor uses PL2303/PL2301 chip, so it would create a path on /dev, if its the first device, it will appear as "/dev/ttyUSB0", but you may also see the list reading the proc path (like "cat /proc/bus/usb/devices").
Under Windows it usually creates a virtual "COM", just go to device manager and check the port.
When you are sure about how the HW talks to your system, you may use QExtSerialPort for wrapping the system API and talk to the device.
Way too hard and too platform specific, using weird Windows Registry keys or rely on hard wired device nodes on Linux.
You are on the right way. Get QextSerialPort or QSerialDevice (which I preffer in my projects, because it got integrated in Qt5), have a look at the examples and simply use it. In both libraries you get some kind of port enumerator class which returns you a list of all configures serial ports. Only platform/device specific settings you will have to do manually (like getting RS485 in half-duplex mode on my current embedded project), but "standard" problems are perfectly encapsulated in a QIODevice implementation.
You can use both QextSerialPort and QSerialDevice like a file. Open it (instead of a filename you specify the device name ie. "COM1" on Windows or "/dev/tty0" on Linux, depending on your configuration) and then read or write like you are doing it with an ordinary QFile, QBuffer, Qwhatever-inherits-from-QIODevice.
If you have any problems opening the port and communicating, don't hesitate to ask! :)