# FreeBSD Carrier Detection



## rstor (Jun 13, 2013)

Regarding carrier detection on FreeBSD 9.1 being run within Virtual Box: 

I used a USB-serial dongle which shows up as ttyu0 on the *Free*BSD machine. Carrier detection appears to work. When I establish a null modem connection I receive a login prompt. If I login, and then unplug and plug back the cable, I get the login prompt again and the old session does not continue. This is the correct behaviour to my understanding, however I am curious of the way the getty process behaves, especuially on bootup in FreeBSD.

Question:

The line in my /etc/ttys file is as follows:


```
ttyu0 "/usr/libexec/getty std.300" dialup on
```

I then issued the command `kill -HUP 1` and restarted the system with nothing plugged into the serial port. Reading the documentation online, it is my understanding that when the system starts up and no carrier is detected, when issuing the `ps ax` command, the result I am supposed to see should be something as follows:


```
114 ?? I 0:00.10 /usr/libexec/getty std.300 ttyu0
```

However I instead see a similar output to the above but the question marks are replaced by letters. Per the documentation online it indicates that if something like this is displayed it means that 





> getty has completed its open on the communications port. This could indicate a problem with the cabling or a misconfigured modem, because getty should not be able to open the communications port until carrier detect has been asserted by the modem.



I figured that since nothing is connected into the serial port, perhaps the voltage levels may be floating, instead of being held at the negative voltage which would indicate no carrier. I therefore applied a negative voltage to the CD line and restarted the system. Upon restart I issuing the `ps -ax` command and the result was as before, letters instead of the question marks. I then manually applied a positive voltage to the CD line and then a negative voltage again. I had to do it a couple times however eventually it showed up with question marks. I then was able to toggle back and forth, positive voltage resulted in letters, negative voltage on CD line resulted in question marks.

Why is it that when a negative voltage is applied to the CD line, upon system start-up, getty indicates via the `ps -ax` command that it has opened the port? [i.e. letters appear instead of question marks] I would expect that with a negative voltage applied to the CD line, upon restart it would show up with ??

I need to toggle the voltage between negative to positive and then back to negative (sometimes I need to do it a couple times) for it to eventually show up with ?? and then it would toggle back and forth as I switch the voltages thereafter.


----------



## rstor (Jun 16, 2013)

I have found out where my problem was. Here is what I did:

I took two DB9 Male-Female connectors and removed all pins except receive, transmit, and ground. I connected the two connectors to each end of my null modem cable. The end result is a null modem cable that will only use these three lines.

I installed FreeBSD on an actual machine with a serial port (instead of using FreeBSD on VM Virtual Box with a USB-serial dongle). I connected my modified null modem cable to the FreeBSD  machine and the other end to a PC.

Executing `ps -ax` on the above FreeBSD machine resulted in the following:

```
749 ?? S 0:00.01 /usr/libexxec/getty std.300 ttyu0
```

This is the correct behaviour to my understanding. 

Using the modified cable on the virtual FreeBSD machine connected to a PC and executing `ps -ax` resulted in the following:

```
683 u0 Ss+ 0:00.06 /usr/libexec/getty std.300 ttyu0
```

Conclusion:

On the virtual FreeBSD machine which had a USB serial dongle, getty opens the communication port on system startup which it should not do to my understanding. On a real system it performs as indicated in the documentation.


----------

