C# Seri Port Haberleşmesi (Yardım)
-
arkadaşlar netten bulduğum bi program(seri porttan veri okuma ve yazma) var ancak çalıştıramadım. Yardım ederseniz sevinirim.
Hata şöyle: unhandled exeption has occured in your application. If you click Countinue, the application will ignore this error and attempt to continue...
The port "COM1" does not exist. ?????
Kod da şöyle arkadaşlar.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Seri_Port
{
public partial class AHY : Form
{
public AHY()
{
InitializeComponent();
}
private void yaz_Click(object sender, EventArgs e)
{
if (!serialPort1.IsOpen)
{
serialPort1.Open();
}
string sendmesaj = textBox1.Text + "-->>>>";
serialPort1.WriteLine(sendmesaj);
}
private void button2_Click(object sender, EventArgs e)
{
string i = serialPort1.ReadLine();
textBox2.Text = "<<<<---" + i;
serialPort1.Close();
}
}
}
-
kod mu eksik yoksa "serialPort1" değişkeni tanımlanmamış mı :| ?
-
hocam netten baktığımda components'larda 'serial port' sekmesini forma ekleyince olduğu yazıyordu? Ben de öle yaptım ancak yeni de başladım bu işe?
-
forma surukleyip biraktigin serial port un ustune tikayip properties ten COM4-5-6 veya daha ust numaralarda bos bir COM icin denesene , mesela laptoptayim suan COM1 icin olmuyor fakat COM5 bostaydi , COM5 icin hata vermedi.
edit: ayrıca "http://www.tahribat.com/forumdisplayfolder.asp?folderid=89422" linkine girip , C# icin olan kitaplari indir istersen , çok faydasini goruceksindir.
