# Tandberg RDX: how to find out when media is inserted



## zwieblum (Jun 22, 2021)

I have a Tandberg RDX drive attached to USB. When booting, the device /dev/da0 is created. dmesg says:

```
da0 at umass-sim0 bus 0 scbus7 target 0 lun 0
da0: <TANDBERG RDX 0044> Removable Direct Access SCSI-3 device
da0: Serial Number TANDBERGRD6520236564          
da0: 40.000MB/s transfers
da0: Attempt to query device size failed: NOT READY, Medium not present
da0: quirks=0x2<NO_6_BYTE>
```
That "Medum not present" is always in the log, no matter if or if not a meduim is present. Theres also no output to the log when a medium is inserted. "gpart" list" does not show anything da0, even when a medium is inserted. But I can mount/unmount the medium if its present.

When it was installed two years ago (12.1 I think) I was able to force a media detection by issuing "usbconfig reset". Then  "gpart" listed da0, too. Now the box is running 12.2-p8 and I cannot find a way to detect the precence of a media.

For reference: running linux on the very same device on the same machine creates events for media inserted/removed. So the hardware is working.


----------



## covacat (Jun 22, 2021)

id play with camcontrol
tur reset rescan


----------



## tingo (Jun 22, 2021)

and inquiry.


----------



## Alain De Vos (Jun 22, 2021)

Be carefull when on reboot devices get renumbered. I found myself formating the wrong one.


----------



## zwieblum (Jun 24, 2021)

Formating the wrong one is kind of bad 

For now I settled on replacing "usbconfig reset" with "camcontrol inq da0": it does not generate any log entries, so Im happy.

I also tried "camcontrol reprobe da0", but that creates one disturbing line when no media is inserted:

```
g_vfs_done():da0[READ(offset=65536, length=8192)]error = 6
```

What sill bothers me is why there are no "media inserted" events any more.


----------



## Tieks (Jun 24, 2021)

zwieblum said:
			
		

> ... there are no "media inserted" events any more



Just a guess, because a different device gave me similar problems some time ago. That problem was caused by this part in /etc/devd.conf:


```
# Rescan SCSI device-names on attach, but not detach.  However, it is
# disabled by default due to reports of problems.
#
attach 0 {
<------>device-name "$scsi-controller-regex";
//<---->action "camcontrol rescan all";
};
```

The action was made to a comment here, that's what caused my problem. You might want to take a look at that part too, see `man devd` and `man devd.conf` for details. 
If it is indeed this action that is missing, the proper solution is to create a device specific entry for your Tandberg in /usr/local/etc/devd.  And yes, the proper solution is on my to-do list.


----------



## zwieblum (Jun 24, 2021)

Almost  The "attach" event is generated when the RDX drive is attached. That part works. The "attach" event is not generated, when a media is inserted into the already attached RDX drive - that's my problem.


----------



## covacat (Jun 24, 2021)

the media change notifications should come thru geom subsystem
try sysctl _kern.geom.debugflags=1_


----------



## Tieks (Jun 24, 2021)

zwieblum said:
			
		

> The "attach" event is not generated



Instead of a USB/ATTACH event you could have a GEOM/CREATE event, as covacat already pointed out. You could also try to create /usr/local/etc/devd/tandberg.conf with only this:

```
# Testing a device using vid:pid only.
notify 200 {
    match "vendor"      "0x0001";
    match "product"     "0x0002";
    action "logger 0-$system 1-$subsystem 2-$type 3-$class 4-$devclass 5-$mode 6-$intclass 7-$intprotocol 8-$intsubclass 9-$function a-$notify";
};
```

Make sure vendor and product are correct, enter `service devd restart` and see what output you get when you attach it and when you insert a medium. You may need other variables, see `man devd.conf` for a list.


----------



## zwieblum (Jun 26, 2021)

I have added the devd config, now I wait for monday to see what happes. If does not do anything I'll go for _kern.geom.debugflags_.  Thank you all for the suggestions.


----------



## zwieblum (Jul 9, 2021)

Ok. watched this over last weeks, but the devd rule never gets triggered. I have to poll the medium - or better, I have to try to mount it. If it's not present, I get 


> kernel: g_vfs_done():da0[READ(offset=65536, length=8192)]error = 6


Else the mount succeeds.


----------



## ccammack (Jul 9, 2021)

Sorry, are you watching for `devd` events using `nc` or is there another way?

`# nc -U /var/run/devd.pipe`


----------



## zwieblum (Jul 9, 2021)

That sheds some light on the case  I'm using the devd rule from above - adjusted for my setting. Using your command I get every 5 sec:


> !system=CAM subsystem=periph type=error device=da0 serial="TANDBERGRD6520236564          " cam_status="0xcc" scsi_status=2 scsi_sense="70 02 3a 00" CDB="00 00 00 00 00 00 "


Whe I inser a medium I get:


> !system=DEVFS subsystem=CDEV type=MEDIACHANGE cdev=da0
> !system=GEOM subsystem=DEV type=MEDIACHANGE cdev=da0
> !system=CAM subsystem=periph type=error device=da0 serial="TANDBERGRD6520236564          " cam_status="0xcc" scsi_status=2 scsi_sense="70 06 28 00" CDB="00 00 00 00 00 00 "
> !system=DEVFS subsystem=CDEV type=CREATE cdev=ufsid/60d199d28e5b4e4d
> !system=GEOM subsystem=DEV type=CREATE cdev=ufsid/60d199d28e5b4e4d


and no more lines with "type=error". Now I'm going to try to put tis in a devd rule ... will need to do some reading


----------



## zwieblum (Jul 9, 2021)

For the record: This is the correct udev rule:


> # /usr/local/etc/devd/tandberg.conf (Geändert)                                                                                                                                          Row 6    Col 1
> # Testing a device using vidid only.
> notify 200 {
> match "system"      "GEOM";
> ...


.. and that trick with nc is really neat one


----------



## ccammack (Jul 9, 2021)

Good. Eject should give a different set of messages. I'm not sure how the `devd` rules cascade, but there might be a way to match _serial="TANDBERGRD6520236564" _followed by _system=GEOM subsystem=DEV type=CREATE _to avoid accidental triggering by other devices.


----------



## zwieblum (Jul 9, 2021)

Luckily that's a point taken care of in my little backup program


----------

