Dangerous Prototypes

Dangerous Prototypes => USB Infrared Toy => Topic started by: tridy on May 14, 2015, 12:02:51 pm

Title: [Not Possible] Send and Receive IR signal over TX RX
Post by: tridy on May 14, 2015, 12:02:51 pm
Hello.

When I connect USB-to-Serial cable to IRTX, IRRX, +5v, and GND, I am able to see that the signal is coming through via terminal.

[attachment=1]

[attachment=0]


So, as soon as I connect it, the "I" led stays always on, like it's in bootloader mode. (it's off when using the USB connection and blinks on data getting received). Does it have to be on or is there something wrong? It would be nice to have the same blinking led functionality when using serial and the IR signal is received. When I disconnect it and go back to USB cable, the led works as expected.

thanks!
Title: Re: Send and Receive IR signal over TX RX
Post by: tridy on May 15, 2015, 12:54:13 pm
Ok, lets simplify the task.
I have 2 ways to connect the IR Toy, USB and Serial (via USB-to-Serial adapter).
I have written the unit tests that uses one COM port or another to get the version from the IR Toy. Basically by sending 'v' command to serial port, it should return 'v222'.

- USB works as expected
- Serial never returns a version (Times out after 5 seconds)

I can see the adapter blinking, signifying that the data was sent to the Toy but the Toy never sets the version number to be read. It's either I wire it incorrectly or I am missing something. Here is how it is connected via Serial:

[attachment=1]

and unit tests code (the same test is executed for both tests, just different ports:

Code: [Select]
using System;
using System.IO.Ports;
using System.Threading;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace IrToyLibrary.UnitTests
{
    [TestClass]
    public class GettingVersionTests
    {
        private const string USB_COM_PORT = "COM3";
        private const string SERIAL_COM_PORT = "COM4";

        [TestMethod]
        public void CanGetViaUSB()
        {
            var version = GetVersionFromComPort(USB_COM_PORT);
            Assert.AreEqual(expected: "V222", actual: version);
        }

        [TestMethod]
        public void CanGetViaSerial()
        {
            var version = GetVersionFromComPort(SERIAL_COM_PORT);
            Assert.AreEqual(expected: "V222", actual: version);
        }

        private string GetVersionFromComPort(string comPort)
        {
            var serialPort = new SerialPort
            {
                PortName = comPort,
                BaudRate = 115200,
                ReadTimeout = 3000
            };

            serialPort.Open();

            byte[] CMD_VERSION = { Convert.ToByte(Convert.ToInt32('v')) };
            serialPort.Write(CMD_VERSION, 0, CMD_VERSION.Length);

            int secondsWaiting = 0;
            while (serialPort.BytesToRead < 1)
            {
                if (secondsWaiting++ > 5)
                {
                    throw new TimeoutException("Timeout waiting for version string.");
                }

                Thread.Sleep(TimeSpan.FromSeconds(1));
            }

            string version = serialPort.ReadExisting();

            serialPort.Close();

            return version;
        }
    }
}

Has anyone made it work via Serial?

Thanks!
Title: Re: Send and Receive IR signal over TX RX
Post by: tridy on May 15, 2015, 03:22:16 pm
Well, well.

I have been looking around, writing emails, asking people for help, and it seems like the Toy's firmware does not support the communication via Serial in the same way as USB does.

So, case closed.

Got to look for other solutions.
Title: Re: [Not Possible] Send and Receive IR signal over TX RX
Post by: Barf on May 15, 2015, 05:41:36 pm
IIRC, the signals IRTX and IRRX are shortcuts direct to/from the hardware. To communicate with the PIC, you should use RX and TX pins instead, I think.
Title: Re: [Not Possible] Send and Receive IR signal over TX RX
Post by: tridy on May 15, 2015, 09:55:20 pm
thanks, Barf.

I tried them as well, tried to cross them as well. 4 combinations. no result.
one thing that I think signifies that it will not work is that the orange "I" (usually signifying bootloader) led is always on. When using USB however the led is off and blinks a little bit when it receives/catches some IR data.
Title: Re: [Not Possible] Send and Receive IR signal over TX RX
Post by: Qwlciguk on May 16, 2015, 06:24:45 pm
The Tx/Rx pins if I remember correctly are only there to provide a USB to serial convertor function.  That is, your computer opens the virtual comm port via USB and the PIC dutifully relays all communications to/from the Tx/Rx pair.  Also, it only does this, after the mode has been switched appropriately.  In no way, shape or form, will it still perform IR functions when in that mode.  For all I know, the USB to serial capability isn't even in the current FW anymore.

All that said, considering all of the difficulties that folks have with drivers and what not, having the option to use the Rx/Tx pair as the normal I/O for the IRToy, would be a great feature.  If it were my design, I never would've gone with USB to begin with, just stuck with standard old rs232.
Title: Re: [Not Possible] Send and Receive IR signal over TX RX
Post by: Simpkins on May 17, 2015, 11:47:17 am
[quote author="Qwlciguk"]
For all I know, the USB to serial capability isn't even in the current FW anymore.
[/quote]

Well, at least on my firmware it is and funny enough this is the feature of the IR TOY that seems to work the best.

( ! ) Fatal error: Uncaught exception 'Elk_Exception' with message 'Please try again. If you come back to this error screen, report the error to an administrator.' in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
( ! ) Elk_Exception: Please try again. If you come back to this error screen, report the error to an administrator. in /var/www/dangerousprototypes/forum/sources/database/Db-mysql.class.php on line 696
Call Stack
#TimeMemoryFunctionLocation
10.00882064640session_write_close ( )...(null):0
20.00912196216ElkArte\sources\subs\SessionHandler\DatabaseHandler->write( )...(null):0
30.00912196992Database_MySQL->query( ).../DatabaseHandler.php:119
40.05262335712Database_MySQL->error( ).../Db-mysql.class.php:273