Under what circumstances should a custom module reserve pins?
For example, I assume that a module using UART on Socket 11 of the Spider should reserve pins 4 and 5 for TX/RX, right?
When I try that, I get this:
[quote]Using mainboard GHIElectronics-FEZSpider version 1.0
#### Exception Gadgeteer.Socket+PinConflictException - 0x00000000 (1) ####
#### Message:
Unable to configure the MidiModule module using socket 11 (pin 4). There is a conflict with the MidiModule module using socket 11 (pin 4). Please try using a different combination of sockets.
#### Gadgeteer.Socket::ReservePin [IP: 003a] ####
#### Gadgeteer.Interfaces.Serial::.ctor [IP: 00ec] ####
#### Gadgeteer.Modules.PeteBrown.MidiModule::.ctor [IP: 007a] ####
#### GadgeteerMidiTest.Program::.ctor [IP: 0006] ####
#### GadgeteerMidiTest.Program::Main [IP: 000b] ####
A first chance exception of type ‘Gadgeteer.Socket.PinConflictException’ occurred in Gadgeteer.dll
An unhandled exception of type ‘Gadgeteer.Socket.PinConflictException’ occurred in Gadgeteer.dll[/quote]
However, if I run without that check, it works. I’m not sure if another module I’m using could potentially conflict, or if I’m doing something wrong with the check.
public MidiModule(int socketNumber)
{
Socket socket = Socket.GetSocket(socketNumber, true, this, null);
// need a UART/USART socket.
if (!socket.SupportsType('U'))
{
throw new GT.Socket.InvalidSocketException("Socket '" + socketNumber + "' does not support the MIDI module. Please plug the MIDI module into a socket labeled 'U'.");
}
// can't share the send/receive pins
try
{
socket.ReservePin(Socket.Pin.Four, this);
socket.ReservePin(Socket.Pin.Five, this);
}
catch (Exception e)
{
throw new GT.Socket.InvalidSocketException("Could not reserve required pins for MIDI serial communications on socket '" + socketNumber + "'.");
}
// initialize serial comms
_serial = new GTI.Serial(
socket,
31250,
GTI.Serial.SerialParity.None,
GTI.Serial.SerialStopBits.One,
8,
GTI.Serial.HardwareFlowControl.NotRequired,
this);
// open ze port
_serial.Open();
}
Awesome MSPaint artwork attached.
Pete