<p>Checking the <a href="https://github.com/mindboards/ev3sources/blob/78ebaf5b6f8fe31cc17aa5dce0f8e4916a4fc072/lms2012/c_output/source/c_output.c#L27" rel="nofollow">source</a> <a href="https://github.com/mindboards/ev3sources/blob/78ebaf5b6f8fe31cc17aa5dce0f8e4916a4fc072/lms2012/d_pwm/Linuxmod_AM1808/d_pwm.c#L2226" rel="nofollow">code</a>, it appears that the <code>opOutput_Get_Type</code> command is not implemented. In both links, it is mentioned in the comments, but there is nothing in the actual code.</p>

<p>Unfortunately, I am not finding a different way to get this information.</p>

CC BY-SA 3.0
2014-11-12T06:32:00.180Z
Thanks for the tip. I've found command opOUTPUT_GET_TYPE = 0xA0 in bytecodes.h and parameters which it takes http://topikachu.github.io/python-ev3/OutputLibrary.html.
user4053
CC BY-SA 3.0
2014-11-11T22:34:45.200Z
2014-11-11T22:34:45.200Z
David Lechner
<p>The one who wants to know device type should use direct command:</p>

<pre><code>Instruction        opInput_Device (CMD, ...)
Opcode             0x99
CMD                GET_TYPEMODE = 0x05
Arguments
                   (Data8) LAYER – Specify chain layer number [0 - 3]
                   (Data8) NO – Port number [0 - 3]
Returns
                   (Data8) TYPE
                   (Data8) MODE - Device mode [0-7]
</code></pre>

<p>In order to discover all ports we should send</p>

<pre><code>unsigned const char opOutput_Get_Type[] {
    0x35, 0x00,                                 //Message size = 53 bytes (0x35 hex)
    0x00, 0x00,                                 //Message Counter
    0x00,                                       //DIRECT_COMMAND_REPLY
    0x10, 0x00,                                 //16 values will be returned... 8 pairs (type, mode)
    0x99, 0x05, 0x00, 0x00, GV0(0), GV0(1),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_A, TYPE, MODE
    0x99, 0x05, 0x00, 0x01, GV0(2), GV0(3),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_B, TYPE, MODE
    0x99, 0x05, 0x00, 0x02, GV0(4), GV0(5),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_C, TYPE, MODE
    0x99, 0x05, 0x00, 0x03, GV0(6), GV0(7),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_D, TYPE, MODE
    0x99, 0x05, 0x00, 0x10, GV0(8), GV0(9),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_1, TYPE, MODE
    0x99, 0x05, 0x00, 0x11, GV0(10), GV0(11),   //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_2, TYPE, MODE
    0x99, 0x05, 0x00, 0x12, GV0(12), GV0(13),   //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_3, TYPE, MODE
    0x99, 0x05, 0x00, 0x13, GV0(14), GV0(15),   //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_4, TYPE, MODE
};
</code></pre>

<p>In return we'll get response i.e.:</p>

<pre><code>13 00 00 00 02 7e 00 7e 00 7e 00 7e 00 08 00 07 00 07 00 7e 00
</code></pre>

<p>which stands (based on <a href="http://ev3.fantastic.computer/doxygen/types.html" rel="nofollow">http://ev3.fantastic.computer/doxygen/types.html</a>)</p>

<pre><code>13 00   //message size = 19 bytes
00 00   //message counter
02      //success
7e 00   //nothing on port A
7e 00   //nothing on port B
7e 00   //nothing on port C
7e 00   //nothing on port D
08 00   //M-MOTOR-DEG on port 1
07 00   //L-MOTOR-DEG on port 2
07 01   //L-MOTOR-ROT on port 3
7e 00   //nothing on port 4
</code></pre>

CC BY-SA 3.0
2015-10-12T14:29:57.427Z
2015-10-12T14:29:57.427Z
user4053
<p>I would like to know what kind of motor (XL, L) is connected to EV3 output port (A|B|C|D). I need to use direct command:</p>

<pre><code>Instruction        opOutput_Get_Type (LAYER, NO, *TYPE)
Opcode             0xA0
Arguments          (Data8) LAYER – Specify chain layer number [0 - 3]
                   (Data8) NO – Port number [0 - 3]
                   (Data8) *TYPE
</code></pre>

<p>so request should looks like:</p>

<pre><code>unsigned const char opOutput_Get_Type[] {
    0x09, 0x00, // bytes in message
    0x00, 0x00, // message counter
    0x00,       // DIRECT_COMMAND_REPLY
    0x01, 0x00, // 1 value will be returned
    0xA0,       // opOutput_Get_Type
    LC0(0),     // LAYER 0, first brick in chain
    LC0(0),     // port A
    GV0(0)      // returned value
};
</code></pre>

<p>When I send it to brick a get response:</p>

<pre><code>04000000 0400
          ^-
          DIRECT_REPLY_ERROR
</code></pre>

<p>which stands that error occurred. Motor is connected to port A. What am I doing wrong?</p>

<mindstorms><ev3><programming><motor>
Lego EV3 - Get output device type, opOUTPUT_GET_TYPE
user4053
# Lego EV3 - Get output device type, opOUTPUT_GET_TYPE

(Asked by: username_0 on 2014-11-11)

I would like to know what kind of motor (XL, L) is connected to EV3 output port (A|B|C|D). I need to use direct command:
Instruction        opOutput_Get_Type (LAYER, NO, *TYPE)
Opcode             0xA0
Arguments          (Data8) LAYER – Specify chain layer number [0 - 3]
                   (Data8) NO – Port number [0 - 3]
                   (Data8) *TYPE

so request should looks like:
unsigned const char opOutput_Get_Type[] {
    0x09, 0x00, // bytes in message
    0x00, 0x00, // message counter
    0x00,       // DIRECT_COMMAND_REPLY
    0x01, 0x00, // 1 value will be returned
    0xA0,       // opOutput_Get_Type
    LC0(0),     // LAYER 0, first brick in chain
    LC0(0),     // port A
    GV0(0)      // returned value
};

When I send it to brick a get response:
04000000 0400
          ^-
          DIRECT_REPLY_ERROR

which stands that error occurred. Motor is connected to port A. What am I doing wrong?

**Tags:** mindstorms, ev3, programming, motor


---

## 2 answers

### Answer by username_1 on 2014-11-11. Score: 2

Checking the [source](https://github.com/mindboards/ev3sources/blob/78ebaf5b6f8fe31cc17aa5dce0f8e4916a4fc072/lms2012/c_output/source/c_output.c#L27) [code](https://github.com/mindboards/ev3sources/blob/78ebaf5b6f8fe31cc17aa5dce0f8e4916a4fc072/lms2012/d_pwm/Linuxmod_AM1808/d_pwm.c#L2226), it appears that the `opOutput_Get_Type` command is not implemented. In both links, it is mentioned in the comments, but there is nothing in the actual code.

Unfortunately, I am not finding a different way to get this information.

> **Comments:**
> **username_0**: Thanks for the tip. I've found command opOUTPUT_GET_TYPE = 0xA0 in bytecodes.h and parameters which it takes http://topikachu.github.io/python-ev3/OutputLibrary.html.  

---

### Answer by username_0 on 2015-10-12. Score: 0

The one who wants to know device type should use direct command:
Instruction        opInput_Device (CMD, ...)
Opcode             0x99
CMD                GET_TYPEMODE = 0x05
Arguments
                   (Data8) LAYER – Specify chain layer number [0 - 3]
                   (Data8) NO – Port number [0 - 3]
Returns
                   (Data8) TYPE
                   (Data8) MODE - Device mode [0-7]

In order to discover all ports we should send
unsigned const char opOutput_Get_Type[] {
    0x35, 0x00,                                 //Message size = 53 bytes (0x35 hex)
    0x00, 0x00,                                 //Message Counter
    0x00,                                       //DIRECT_COMMAND_REPLY
    0x10, 0x00,                                 //16 values will be returned... 8 pairs (type, mode)
    0x99, 0x05, 0x00, 0x00, GV0(0), GV0(1),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_A, TYPE, MODE
    0x99, 0x05, 0x00, 0x01, GV0(2), GV0(3),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_B, TYPE, MODE
    0x99, 0x05, 0x00, 0x02, GV0(4), GV0(5),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_C, TYPE, MODE
    0x99, 0x05, 0x00, 0x03, GV0(6), GV0(7),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_D, TYPE, MODE
    0x99, 0x05, 0x00, 0x10, GV0(8), GV0(9),     //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_1, TYPE, MODE
    0x99, 0x05, 0x00, 0x11, GV0(10), GV0(11),   //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_2, TYPE, MODE
    0x99, 0x05, 0x00, 0x12, GV0(12), GV0(13),   //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_3, TYPE, MODE
    0x99, 0x05, 0x00, 0x13, GV0(14), GV0(15),   //opInput_Device, GET_TYPEMODE, LAYER_0, PORT_4, TYPE, MODE
};

In return we'll get response i.e.:
13 00 00 00 02 7e 00 7e 00 7e 00 7e 00 08 00 07 00 07 00 7e 00

which stands (based on http://ev3.fantastic.computer/doxygen/types.html)
13 00   //message size = 19 bytes
00 00   //message counter
02      //success
7e 00   //nothing on port A
7e 00   //nothing on port B
7e 00   //nothing on port C
7e 00   //nothing on port D
08 00   //M-MOTOR-DEG on port 1
07 00   //L-MOTOR-DEG on port 2
07 01   //L-MOTOR-ROT on port 3
7e 00   //nothing on port 4


---

