I want to interface with the Visual Studio DexDrive

Start a work log and update it occasionally with your projects progress
Post Reply
Meta
Active PSXDEV User
Active PSXDEV User
Posts: 40
Joined: Dec 14, 2015

I want to interface with the Visual Studio DexDrive

Post by Meta » December 23rd, 2015, 11:49 pm

Hi:
I want to interface DexDrive Explorer to control the device.
Image


I have open.
Image
Image

The original is this Explorer 2.0.
Image

Here is a source code control in C DexDrive Linux, but do not quite understand. I want to pass it on to Visual C #.
https://github.com/fbriere/linux-dexdrive

As shown in the protocol indicated below.
https://github.com/fbriere/linux-dexdri ... otocol.txt

I tried to ignore this part in Visual C #.
COMMANDS
--------

For all commands specifying a (16-bit) frame number, <lsb> and <msb> are,
respectively, its least and most significant bytes. Make sure to pay close
attention to the order, as it varies between commands.

Note that the Nintendo 64 DexDrive will get stuck if it is sent an
incomplete command. At that point, the only solution is to unplug it
completely, and plug it back (power first, then serial).

0x00 INIT

Args: <17 bytes>
Reply: ID

Initializes the DexDrive; see the POUTING section below.

The contents of the 17 bytes does not appear to have any significance,
except for determining the contents of the "weird" byte in the ID reply.
See the WEIRD FORMULA section below for more details.

InterAct's DexPlorer software uses the following hard-coded string:

10 29 23 be 84 e1 6c d6 ae 52 90 49 f1 f1 bb e9 eb
Send these 17 bytes but nothing happens.

Code: Select all

        private void button6_Click(object sender, EventArgs e)
        {
            byte[] mBuffer = new byte[17];
            mBuffer[0] = 0x10;
            mBuffer[1] = 0x29;
            mBuffer[2] = 0x23;
            mBuffer[3] = 0xBE;
            mBuffer[4] = 0x84;
            mBuffer[5] = 0xE1;
            mBuffer[6] = 0x6C;
            mBuffer[7] = 0xD6;
            mBuffer[8] = 0xAE;
            mBuffer[9] = 0x52;
            mBuffer[10] = 0x90;
            mBuffer[11] = 0x49;
            mBuffer[12] = 0xF1;
            mBuffer[13] = 0xF1;
            mBuffer[14] = 0xBB;
            mBuffer[15] = 0xE9;
            mBuffer[16] = 0xEB;
            serialPort1.Write(mBuffer, 0, mBuffer.Length);
        }
How many works DexDrive baud serial port?

They can help in this project to create an interface with Visual C #.

Image

;)

Gradius
Verified
Extreme PSXDEV User
Extreme PSXDEV User
Posts: 220
Joined: Sep 09, 2012
I am a: IT Consultant, Systems Integrator
PlayStation Model: 7501
Location: Chile

Post by Gradius » December 24th, 2015, 2:35 am

Did you tried to contact the author?

Frédéric Brière <[email protected]>

The code seems fine, but keep in mind it uses Linux bases, so stuff like I/O is much easier, like /dev/floppy (as he used).

Meta
Active PSXDEV User
Active PSXDEV User
Posts: 40
Joined: Dec 14, 2015

Post by Meta » December 24th, 2015, 8:49 am

Hey there:

I sent a message to the author before posting here. I'm still waiting. By the way, I've missed things.

Every command or reply is prefixed With the string "IAI" (0x49 0x41 0x49)
(possibly standing for "InterAct Accessories, Inc."). A single byte Follows
Which indicating Being command or reply is sent.

0x49 0x41 0x49 0x00 0x10 0x29 0x23 0x84 0xE1 0xBE 0x6C 0x52 0x90 0x49 0xd6 0xAE 0xf1 0xf1 0xBB 0xe9 0xEB

Since about 7 years or more who posted the code, not if the author is still alive in this world of programming and DexDrive. For now I'm still waiting to respond.

When I get something, I'll let you know, while I'm trying. If anyone has knowledge, you can help.

Regards.

Edit
:


Image
I've got to answer me? IAI, but the LED lights, at least for now.

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.IO.Ports; // No olvidar.

namespace DexPlorer
{
    public partial class Form1 : Form
    {
        // Utilizaremos un string como buffer de recepción.
        string Recibidos;

        public Form1()
        {
            InitializeComponent();

            // Puerto abierto desde que arranca la aplicación.
            if (!serialPort1.IsOpen)
            {
                try
                {
                    serialPort1.Open();
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            serialPort1.DataReceived += new SerialDataReceivedEventHandler(Recepcion);
        }

        // Al recibir datos.
        private void Recepcion(object sender, SerialDataReceivedEventArgs e)
        {
            // Acumula los caracteres recibidos a nuestro 'buffer' (string).
            Recibidos += serialPort1.ReadExisting();

            // Invocar o llamar al proceso de tramas.
            Invoke(new EventHandler(Actualizar));

            //Invoke(new EventHandler(IniciarTimer));
        }

        // Procesar los datos recibidos en el bufer y extraer tramas completas.
        private void Actualizar(object sender, EventArgs e)
        {
            // Para ver lo que envía desde el DexDrive hacia esta interfaz de C#.
            // Asignar el valor de la trama al richTextBox.
            richTextBox1.Text = Recibidos;

            // Selecciona la posición final para leer los mensajes entrantes.
            richTextBox1.SelectionStart = richTextBox1.Text.Length;

            // Mantiene el scroll en la entrada de cada mensaje.
            richTextBox1.ScrollToCaret();


            switch (Recibidos)
            {
                // Aquí hay que ejecutar los case cada vez que DexDrive envía
                // los datos.

            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            byte[] mBuffer = new byte[21];
            // El famoso IAI.
            mBuffer[0] = 0x49; // I en ASCII.
            mBuffer[1] = 0x41; // A.
            mBuffer[2] = 0x49; // I.

            // El comando INIT de inicio.
            mBuffer[3] = 0x00; // 0.

            // Caractéres extraños.
            mBuffer[4] = 0x10; // DLE.
            mBuffer[5] = 0x29; // ).
            mBuffer[6] = 0x23; // #.
            mBuffer[7] = 0xBE; // ¥.
            mBuffer[8] = 0x84; // ä.
            mBuffer[9] = 0xE1; // ß.
            mBuffer[10] = 0x6C; // l.
            mBuffer[11] = 0xD6; // Í.
            mBuffer[12] = 0xAE; // «.
            mBuffer[13] = 0x52; // R.
            mBuffer[14] = 0x90; // É.
            mBuffer[15] = 0x49; // I.
            mBuffer[16] = 0xF1; // ±.
            mBuffer[17] = 0xF1; // ±.
            mBuffer[18] = 0xBB; // â•—.
            mBuffer[19] = 0xE9; // Ú.
            mBuffer[20] = 0xEB; // Ù.
            serialPort1.Write(mBuffer, 0, mBuffer.Length);

            // Activa el timer para enviar el MAGIC_HANDSHAKE.
            timer1.Enabled = true;
            // timer1.Start(); // También válido para activar el timer1.
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            // Envía MAGIC_HANDSHAKE
            byte[] mBuffer = new byte[1];

            // Comando MAGIC_HANDSHAKE.
            mBuffer[0] = 0x27; // '.
            serialPort1.Write(mBuffer, 0, 1); // Envía el byte. 
            timer1.Enabled = false; // Detiene el timer1 de 100 ms el intervalo.
            // timer1.Stop();
        }
    }
}
I continue to progress. They can provide any help or ideas.

;)

User avatar
Shendo
Verified
C Programming Expert
C Programming Expert
Posts: 250
Joined: Mar 21, 2012
I am a: Programmer
Motto: Never settle
PlayStation Model: SCPH-7502
Discord: ShendoXT
Location: Croatia, EU

Post by Shendo » December 25th, 2015, 12:05 am

My MemcardRex does exactly what you want to achieve.
You can take a look at the source here.

Edit: I also see now that you have posted on my blog. Hope this helps.
Dev console: SCPH-7502, FreePSXBoot, CH340 serial cable.

Meta
Active PSXDEV User
Active PSXDEV User
Posts: 40
Joined: Dec 14, 2015

Post by Meta » December 25th, 2015, 1:13 am

Hi:

I am analyzing the part of DexDrive. For now I'm interested in Visual C # and DexDrive.
Why removed the frame beam original byte on the other invented?

Code: Select all

            SendDataToPort((byte)DexCommands.INIT, new byte[] { 0x10, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD }, 50);
            //SendDataToPort((byte)DexCommands.INIT, new byte[] { 0x10, 0x29, 0x23, 0xbe, 0x84, 0xe1, 0x6c, 0xd6, 0xae, 0x52, 0x90, 0x49, 0xf1, 0xf1, 0xbb, 0xe9, 0xeb }, 50);
Why not use the SerialPort component in the form to reduce code? ;)

Thank you. You've done a good job.

Meta
Active PSXDEV User
Active PSXDEV User
Posts: 40
Joined: Dec 14, 2015

Post by Meta » December 25th, 2015, 11:41 pm

Hello

Has it occurred to you to do something similar with the "Memory Card" from "PlayStation 2" with the same DexDrive and Arduino?

I wait your answer.

Greetings.

Meta
Active PSXDEV User
Active PSXDEV User
Posts: 40
Joined: Dec 14, 2015

Post by Meta » December 31st, 2015, 1:03 am

Image

First test and I can hardly catch the trick, I managed to turn the green LED on the DexDrive. For something one starts. ;) What I have done, only awakens Dedrive withthe green LED showing it is ready to receive commands in which I have not yet scheduled.
In the black box, shown in green letters characters.
For now, this is the code.

Code: Select all

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.IO.Ports; // No olvidar.
using System.Threading;

namespace DexPlorer
{
    public partial class Form1 : Form
    {
        public enum Dex_Comandos
        {
            INIT = 0x00, STATUS = 0x01, READ = 0x02, SEEK = 0x03, WRITE = 0x04, PAGE = 0x05, LIGHT = 0x07, MAGIC_HANDSHAKE = 0x27
        }

        public enum Dex_Respuestas
        {
            POUT = 0x20, ERROR = 0x21, NOCARD = 0x22, CARD = 0x23, CARD_NEW = 0x25, SEEK_OK = 0x27, WRITE_OK = 0x28, WRITE_SAME = 0x29, WAIT = 0x2A, ID = 0x40, DATA = 0x41
        }

        byte[] TRAMAS = { 0x10, 0x29, 0x23, 0xbe, 0x84, 0xe1, 0x6c, 0xd6, 0xae, 0x52, 0x90, 0x49, 0xf1, 0xf1, 0xbb, 0xe9, 0xeb };

        // Utilizaremos un string como buffer de recepción.
        string Recibidos;

        // Buffer para almacenar leer datos de la DexDrive.
        byte[] Leer_Datos = null;

        // Contiene una versión de firmware de un dispositivo detectado.
        string Firmware_Version = null;

        public Form1()
        {
            InitializeComponent();

            // Puerto abierto desde que arranca la aplicación.
            if (!serialPort1.IsOpen)
            {
                try
                {
                    serialPort1.Open();
                }
                catch (System.Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }

            //Dexdrive won't respond if RTS is not toggled on/off
            serialPort1.RtsEnable = false;
            Thread.Sleep(300);
            serialPort1.RtsEnable = true;
            Thread.Sleep(300);

            //DTR line is used for additional power
            serialPort1.DtrEnable = true;

            // Comprobar si DexDrive está conectado al puerto.
            // La detección puede fallar primera o segunda vez, por lo que el comando es enviado 5 veces.
            for (int i = 0; i < 5; i++)
            {
                serialPort1.DiscardInBuffer();
                serialPort1.Write("XXXXX");
                Thread.Sleep(20);
            }

            // Compruebe cadena "IAI".
            Leer_Datos = Leer_datos_del_puerto();
            if ((Leer_Datos[0] != 0x49) || (Leer_Datos[1] != 0x41) || (Leer_Datos[2] != 0x49)) return;

            // Despierta DexDrive arriba (patear desde el modo POUT).
            //Envia_dato_al_puerto((byte)Dex_Comandos.INIT, new byte[] { 0x10, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0xAA, 0xBB, 0xCC, 0xDD }, 50);
            Envia_dato_al_puerto((byte)Dex_Comandos.INIT, new byte[] { 0x10, 0x29, 0x23, 0xbe, 0x84, 0xe1, 0x6c, 0xd6, 0xae, 0x52, 0x90, 0x49, 0xf1, 0xf1, 0xbb, 0xe9, 0xeb }, 50);

            // Compruebe cadena "PSX".
            Leer_Datos = Leer_datos_del_puerto();
            if ((Leer_Datos[5] != 0x50) || (Leer_Datos[6] != 0x53) || (Leer_Datos[7] != 0x58)) return; // "Dispositivo detectado no es un PS1 DexDrive."

            // Obtener la versión del firmware.
            Firmware_Version = (Leer_Datos[8] >> 6).ToString() + "." + ((Leer_Datos[8] >> 2) & 0xF).ToString() + (Leer_Datos[8] & 0x3).ToString();
            label_chivato.Text = Firmware_Version;
            // Enviar señal de handshake magia 10 veces.
            for (int i = 0; i < 10; i++) Envia_dato_al_puerto((byte)Dex_Comandos.MAGIC_HANDSHAKE, null, 0);
            Thread.Sleep(50);

            // Enciende la luz de estado.
            Envia_dato_al_puerto((byte)Dex_Comandos.LIGHT, new byte[] { 1 }, 50);

            // Todo ha ido bien, DexDrive está listo para recibir comandos.
            //return null;

            Recibidos = Encoding.ASCII.GetString(Leer_Datos);

            // Recibidos = Encoding.Default.GetString(Leer_Datos);

            // Para ver lo que envía desde el DexDrive hacia esta interfaz de C#.
            // Asignar el valor de la trama al richTextBox.
            richTextBox1.Text = Recibidos;

            //    // Para ver lo que envía desde el DexDrive hacia esta interfaz de C#.
            //    // Asignar el valor de la trama al richTextBox.
            richTextBox1.Text = Recibidos;

            // Selecciona la posición final para leer los mensajes entrantes.
            richTextBox1.SelectionStart = richTextBox1.Text.Length;

            //serialPort1.DataReceived += new SerialDataReceivedEventHandler(Recepcion);
        }

        // Enviar comando DexDrive en el puerto COM se abrió con un retraso.
        private void Envia_dato_al_puerto(byte Comando, byte[] Dato, int Delay)
        {
            // Borrar todo en el búfer de entrada.
            serialPort1.DiscardInBuffer();

            // Cada comando debe comenzar con la cadena "IAI".
            serialPort1.Write("IAI" + (char)Comando);
            if (Dato != null) serialPort1.Write(Dato, 0, Dato.Length);

            // Espere un tiempo establecido (para la respuesta DexDrive).
            if (Delay > 0) Thread.Sleep(Delay);
        }

        // Captura la respuesta de un DexDrive.
        private byte[] Leer_datos_del_puerto()
        {
            // Buffer para la lectura de datos.
            byte[] Flujo_de_entrada = new byte[256];

            // Leer datos de DexDrive.
            if (serialPort1.BytesToRead != 0) serialPort1.Read(Flujo_de_entrada, 0, 256);

            return Flujo_de_entrada;
        }
    }
}
Thereby still trying to send commands to see if allowed, how to format, read, erase something.

Your program does not read the model as the original Explorer?

Image

I've noticed that your program has everything, except that you have forgotten some details. Your program has to detect when a "Memory Card" inserted. When you remove or insert the memory card, "DeXplorer 2" shows a picture next.

Can you do this in the future?

That will be more complete.

Happy holidays.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests