Advanced Iris Tracking Software

Hey man, you may wish to try by doing o_o.

Hey if you could show me a bit of that Qt code, maybe that might help my issues. A while ago, I sent you a post with the current settings/variables in my VS code. If those could clear anything up, let me know.


Thanks.

If you understand C#, let me know and I could send you a bit of my code.

Paste it. Use the code tags.

Here you go:

using System;
using System.IO.Ports;
using System.ComponentModel;

namespace EyeStuff
{
    class PortDataReceived
    {
        

        public static void Main()
        {
            SerialPort mySerialPort = new SerialPort("COM3");

            mySerialPort.BaudRate = 115200;
            mySerialPort.Parity = Parity.None;
            mySerialPort.StopBits = StopBits.One;
            mySerialPort.DataBits = 8;
            mySerialPort.Handshake = Handshake.None;
            mySerialPort.RtsEnable = true;

            mySerialPort.DataReceived += new SerialDataReceivedEventHandler(DataReceivedHandler);
           
            mySerialPort.Open();

            Console.WriteLine("Press any key to continue...");
            Console.WriteLine();
            Console.ReadKey();
            mySerialPort.Close();
        }

        private static void DataReceivedHandler(object sender, SerialDataReceivedEventArgs e)
        {
            SerialPort sp = (SerialPort)sender;
            string indata = sp.ReadExisting();
            Console.WriteLine("Data Received:");
            Console.Write(indata);
        }
    }
}

Okay, is it working?

The code compiles with no errors and it runs it’s “Press any key” part, but it never prints out any data. At this point, I really don’t know what the problem could be besides that I forgot something. Please let me know if you have any suggestions.

Thanks

Never mind I got it working. However, I wanted to say thank you for your help with the DTR. I forgot one line of code within my script and when I fixed it, everything worked fine. Thanks again.

Great to hear!

Hey I’m back again.
I just wanted to know, if I were to use serial pins to communicate between the two cameras, I would ONLY use pins 4 and 5, right? This is also the simplest way to communicate between the two correct?

Thanks.

Yes, communication is just a serial port between the two devices then. It’s full duplex. You can use the struct module to send binary messages and decode them. Or, you can send data as text.

So I can just use the print function to send text, and then create a statemachine on the other end to receive it?

I guess the better way to phrase it would be, what’s the easiest way to receive data sent by the print command.

No, use this:

import time
from pyb import UART

Always pass UART 3 for the UART number for your OpenMV Cam.

The second argument is the UART baud rate. For a more advanced UART control

example see the BLE-Shield driver.

uart = UART(3, 19200, timeout_char = 1000)

while(True):
uart.write(“Hello World!\r”)
time.sleep(1000)

uart.write() accepts any formatted string. So, you can use python string formatting there. See all the uart methods: class UART – duplex serial communication bus — MicroPython 1.15 documentation

Awesome! So if that sends strings, how to I receive the strings? Also, don’t need to declare the pins anywhere, correct?

UART(3) is fixed to the same I/O pins.

As for receiving data. Please read the UART methods. In general, you want to call any() to see how many bytes are available and then read() that many bytes. If you’d like to see a great example… please see the Pixy Emulation UART script.

OK so I understand the code, but can I give you an example of how my physical pin system is set up? My system has two openMV cams both plugged into the computer via micro-USB cords. The two cams are then connected with two wires vis pins 4 and 5. Lastly, the camera that sends eye data is disconnected from the openMv IDE while the other is connected. Does this all sound about right?


Thanks again.

Yes, make sure both cameras share grounds and that RX plugs into TX of the other camera and TX plugs into RX of the other camera.

Thank you, now I have this code as a start but I know its wrong. Could you tell/show me what else I need to add to it.

uart = UART(3, 19200, timeout_char = 1000)

while(True):
    inData = uart.any()
    print(inData);
    time.sleep(1000)
uart = UART(3, 19200, timeout_char = 1000)

while(True):
    count = uart.any()
    if count:
    	print(uart.read(count))
    	time.sleep(1000)