What is the difference between UART port and serial port in a computer? - drivers

What is the difference, if any, between a UART port and a serial port in a computer?

UART is the abbreviation of Universal Asynchronous Receiver Transmitter, the name of the chip that enables the computer to communicate via a serial line (eg. RS-232, RS-485, RS-422).
The serial port is the RS-232 interface (internally connected to the UART) of the computer.

As #SurDin explained some more points I want to add
1.UART takes data parallel and the help of shift register transfer it bit by bit or takes data bit by bit and reform those into parallel form via communication channel like RS-232,RS-485,RS-422.
2.UART has a baud rate generator, transmeter and a receiver.
3.Its baud rate generator gets clocked either by internal clock or by external source.
communication media linked to serial port which internally connected to UART controller.

Related

SCTP : transmitting with both interfaces at the same time

On my machine, I have 2 interfaces connected to another machine with 2 interfaces as well. I want to use both interfaces at the same time to transfer data. From SCTP view, each machine is an endpoint. So, I used a one-to-one socket. On the server side, I tried to bind INADDR_ANY as well as bind() the first and bindx() the second. On the client side, I tried connect() and connectx(). Whatever I tried, SCTP use only one of the two interfaces at a given time.
I also tested the sctp function on Iperf and the test app in the source code. Nothing works.
What am I missing here? Do you have to send each packet by hand from one or the other address and to one or the other address?
There surely must have a function where you can build several streams where each stream allows the communication between a pair of specific addresses. Then when you send a packet, SCTP chooses automatically which stream to send the packet in.
Thanks in advance!
What you are asking for called concurrent multipath transfer, feature that isn't supported by SCTP (at least not per RFC 4960).
As described in RFC 4960 by default SCTP transmits data over the primary path. Other paths are meant to be monitored by heartbeats and used when transmission over primary path fails.

how to make event marker for Emotiv EPOC (portable EEG)?

I am thinking to measure ERP from Emotiv EPOC (EEG), but in analysis, data should be divided based on timing of onset and offset of stimulus. So, during recording, timing of event, such as onset or offset, needs to be marked. Emotiv PRO offers function to record event marker via serial port. However, I have little knowledge about serial port, and I couldn't marked event.
Could you tell me basic usage for Emotiv PRO about event marker via serial port ?
Below is what I tried.
First, I tried from MATLAB (2018a),
s=serial("/dev/cu.Bluetooth-Incoming-Port");
fopen(s);
then, from Emotiv PRO, I started "set up serial point markers" but response was
Resource Busy.
Second, I tried in different order and from Emotiv PRO, started "set up serial point markers", and then from MATLAB, ran same code, but response from MATLAB was
Cannot connect to the /dev/cu.Bluetooth-Incoming-Port port. Possible reasons are
another
application is connected to the port or the port does not exist.
Third, I tried new MATLAB (2020a),
s=serialport("/dev/cu.Bluetooth-Incoming-Port",9600)
and I started "set up serial point markers" from Emotiv PRO (error didn't appeared),
and, again from MATLAB (2020a)
write(s,1,"uint8")
but, marker didn't appeared in Emotiv PRO.
I confirmed that Emotiv PRO appropriately record marker from key pressing, but I couldn't from serial port.
Oy, this isn't easy. Assuming you have no actual serial port, you need some sort of virtual port. One option is to use a software to create it. then your matlab will send a message to its port and Emptiv will receive the message with another port, both virtual. You will need to make sure the format is set the same way for both sender and receiver, such as BAUD = 115200 bps, Data size = 8 bits etc. Alternatively you can use a null modem cable, to connect a USB wire and convince both sender and receiver that these are two sides of a serial cable. I used it successfully using two computers, one to send the signal and one to receive.

STM32 + Lwip, MCU load due to broadcast packet

Due to the wrong network configuration,
It is assumed that broadcast packet looping has occurred.
STM32 MCU continuously receives broadcast packets.
As a result, the MCU load increases.
Tested on the STM32F746G-DISCOVERY board,
MCU load increased to 70 ~ 80%.
In this case, the polling period is broken and
Our products do not work properly.
Except for using the Serial to Ethernet Controller with TCP / IP Protocol stack,
Is there a way to avoid this problem?
If you detect flooding of broadcast packets, you could in theory temporary disable receiving broadcast packets in the MAC configuration (the ethernet hardware inside the STM32). STM32 MCU can filter packets by broadcast, multicast, receive-all, hash of either sender or received hardward adress.

Difference between port number and socket

I started reading UNIX network programming by W. Richard Stevens and I am very confused between a port and a socket . when I read on internet it said that socket is an endpoint for a connection and for port number it was written that , IP address and port no form a unique pair .
So now my question is that :
(1) What is the difference between these two ?
(2)How are sockets and ports internally manipulated. Are sockets a file ?
(3) How is data sent when we send it using an application ?
(4) If sockets are there then why do we use port numbers ?
Sorry for my English.. Thanks in advance for the reply.
(1) What is the difference between these two ?
A computer running IP networking always has a fixed number of ports -- 65535 TCP ports and 65535 UDP ports. A network packet's header contains a 16-bit unsigned-short field in it specifying which of those ports the packet should be delivered to.
Sockets, on the other hand, are demand-allocated by each program. A socket serves as a handle/interface between the program and the OS's networking stack, and is used to build and specify a context for a particular networking task. A socket may or may not be bound to a port, and it's also possible (and common) to have more than one socket bound to a particular port at the same time.
(2)How are sockets and ports internally manipulated. Are sockets a
file ?
That's totally up to the OS; and different OS's do it different ways. It's unclear what you mean by "a file" in this question, but in general sockets do not have anything to do with the filesystem. On the other hand, one feature of Unix-style OS's is that socket descriptors are also usable in the much same way that filesystem file descriptors are -- i.e. you can pass them to read()/write()/select(), etc and get useful results. Other OS's, such as Windows, do not support that feature and for them you must use a completely separate set of function calls for sockets vs files.
(3) How is data sent when we send it using an application ?
The application calls the send() function (or a similar function such as sendto()), passes in the relevant socket descriptor along with a pointer to the data it wants to send, and then it is up to the network stack to copy that data into a packet and deliver it to the appropriate networking device for transmission.
(4) If sockets are there then why do we use port numbers ?
Because you need a way to communicate with particular programs on other computers, and computer A has no way of knowing what sockets are present (if any) on computer B. But port numbers are fixed, so it is possible for programmers to use them as a rendezvous point for communication -- for example, your web browser knows that a web server is almost certain to be listening for incoming HTTP requests on port 80 whenever the server is running, so it can send its requests to port 80 with a reasonable expectation of getting a useful response back. If it had to specify a socket as a target instead, what would it specify? The server's socket numbers are arbitrary and likely to be different every time the server runs.
1) What is the difference between these two ?
(2)How are sockets and ports internally manipulated. Are sockets a file ?
A socket is (IP+Port):
A socket is like a telephone (i.e. end to end device for communication)
IP is like your telephone number (i.e. address of your socket)
Port is like the person you want to talk to (i.e. the service you want to order from that address)
A socket is part of a process. A process in linux is a file.
(3) How is data sent when we send it using an application ?
Data is sent by converting it to bytes. There is little/big endian problem regarding the ordering in bytes so you have to take this into consideration when coding.
(4) If sockets are there then why do we use port numbers ?
A socket is (address + port) that means the person you want to talk to (port) can be reachable from many telephone numbers (IPs) and thus from many sockets (that does not mean that the person on one telephone number will reply to you the same as the one in the other telephone number because his job here/there may be different).

Send TTL signal through serial port in Matlab

I am trying to send a TTL signal through a serial port using Matlab. I just need to send 1 value to the device so it should be a really simple procedure. My problem is that I don't know if I am not doing this correctly or if the device is not processing the signal. My code is this:
mysignal = serial('com1');
fopen(mysignal);
fwrite(mysignal,1);
I don't think you can output TTL using the actual serial port, as that is RS-232, not TTL logic levels. If you're using the serial port, you'll need a converter, like this. If you're using an FTDI driver/USB cable, that already outputs TTL logic levels, and the code looks good to me, which means the bug is probably on the device end.