Welcome, Guest. Please login or register.

Author Topic: Identifying device type possible ?  (Read 2640 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Identifying device type possible ?
« on: June 24, 2011, 12:50:59 AM »
I want to identify sana drivers from a requester. In my case the reason is that I'm presenting the user with a requester to choose the sana device he wants to use with my program. I found out that if one navigates through the directory tree (on the requester) and chooses serial.device it actually opens with a sana io structure! Maybe there are other non sana devices that will open, haven't tried. But I think the problem is clear, opening a device with another device's io structure might cause problems, maybe the system could even crash.
Looking at a device struct it seems that there is no way to identify the device type or is there ?
Any thoughts on this ?
Maybe I shouldn't even care, it's just that I realized this problem might occur...
« Last Edit: June 24, 2011, 12:54:35 AM by Jose »
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Thomas

Re: Identifying device type possible ?
« Reply #1 on: June 24, 2011, 07:47:31 AM »
If the device is modern enough to support NSD you can use the NSCMD_DEVICEQUERY command to find out its type.

Most devices don't support this, though, so you are actually lost in identifiying the device type. The only hint is that disk-based SANA2 devices must be in Devs:Networks.

You could maintain a white list or a black list of devices which are or aren't SANA2.

But it's probably best to point the requester to Devs:Networks and then trust the user to identify a network driver and not something else.

Offline itix

  • Hero Member
  • *****
  • Join Date: Oct 2002
  • Posts: 2380
    • Show only replies by itix
Re: Identifying device type possible ?
« Reply #2 on: June 24, 2011, 12:38:43 PM »
Quote from: Jose;646821
I want to identify sana drivers from a requester. In my case the reason is that I'm presenting the user with a requester to choose the sana device he wants to use with my program. I found out that if one navigates through the directory tree (on the requester) and chooses serial.device it actually opens with a sana io structure!


It is perfectly fine because serial.device can not know it is SANA IO structure. Once you have opened device you can carefully try to send SANA IO commands to device. If it fails it isnt a network driver. If it succeeds it maybe is.
My Amigas: A500, Mac Mini and PowerBook
 

Offline JoseTopic starter

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 2869
    • Show only replies by Jose
Re: Identifying device type possible ?
« Reply #3 on: June 24, 2011, 07:04:22 PM »
Ok, just for the record, I wrote a more precise error display routine, identifying what's going on, and fiddled with it with a few more devices. My findings are that the behavior is different from device to device. Some won't open at all with my sana io request, others will open but report error when I send an io request, others report an error outside the defined sana errors (atapi.device IIRC), and one (serial.device) even accepted the request and started waiting (would probably get error if I had something connected to the serial port though).
Bottom line, they're interpreting the io request as if it were they're own and sometimes values are accepted.
« Last Edit: June 24, 2011, 07:06:40 PM by Jose »
\\"We made Amiga, they {bleep}ed it up\\"
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: Identifying device type possible ?
« Reply #4 on: June 24, 2011, 07:29:36 PM »
The whole NSD concept is flawed. You can't safely send arbitrary command to some device.