Answer the question
In order to leave comments, you need to log in
How to transfer data from a program written in C# (SerialPort) to Matlab?
Good evening! I ask for your help. It's worth saying in advance that I'm new to this business. I have the task of transferring data from a program written in C# to Matlab. In a C# program, I form an infinite loop that passes data. And in Matlab I created a Simulink model. I checked the performance of each program separately (I just put a jumper between the RX TX ports). For each program I have a separate UART. When I run the program to transfer data, the LEDs on each of the UARTs are lit during data transfer (I think this is a sign of data on the Rx / Tx ports). However, in Matlab I can't display anything.
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;
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
SerialPort port = new SerialPort("COM7", 115200, Parity.None, 8, StopBits.One);
public Form1()
{
InitializeComponent();
if (port != null)
{
port.Open();
byte number = 15;
while(1<2)
{
port.Write(new byte[] { number }, 0, 1);
}
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question