Guys i have modem Wavecom Fasttrack Supreme, and i want make program to receive the SMS instantly, so when i send sms the sms go to my listview1
and i have code like that
public ReciveEmail()
{
InitializeComponent();
getAvaliblePorts();
}
private void button1_Click(object sender, EventArgs e)
{
baca_sms();
}
private void baca_sms()
{
serialPort1.Parity = Parity.None;
serialPort1.DataBits = 8;
serialPort1.StopBits = StopBits.One;
serialPort1.Handshake = Handshake.XOnXOff;
serialPort1.DtrEnable = true;
serialPort1.RtsEnable = true;
serialPort1.NewLine = Environment.NewLine;
serialPort1.Write("AT" + System.Environment.NewLine);
Thread.Sleep(1000);
serialPort1.WriteLine("AT+CMGF=1" + System.Environment.NewLine);
Thread.Sleep(1000);
serialPort1.WriteLine("AT+CMGL=\"ALL\"\r" + System.Environment.NewLine);
Thread.Sleep(3000);
MessageBox.Show(serialPort1.ReadExisting());
Regex r = new Regex(#"\+CMGL: (\d+),""(.+)"",""(.+)"",(.*),""(.+)""\r\n(.+)\r\n");// own creation you must learn
Match m = r.Match(serialPort1.ReadExisting());
while (m.Success)
{
// ShortMessage msg = new ShortMessage();
string a = m.Groups[1].Value;
string b = m.Groups[2].Value;
string c = m.Groups[3].Value;
string d = m.Groups[4].Value;
string ee = m.Groups[5].Value;
string f = m.Groups[6].Value;
// MessageBox.Show(f);
ListViewItem item = new ListViewItem(new string[] { a, b, c, d, ee, f });
listView1.Items.Add(item);
m = m.NextMatch();
}
}
public void getAvaliblePorts()
{
String[] ports = SerialPort.GetPortNames();
comboBox1.Items.AddRange(ports);
}
private void btnOpen_Click(object sender, EventArgs e)
{
try
{
if (comboBox1.Text == "" || comboBox2.Text == "")
{
MessageBox.Show("Please Check your choice !!");
}
else
{
serialPort1.PortName = comboBox1.Text;
serialPort1.BaudRate = Convert.ToInt32(comboBox2.Text);
serialPort1.Open();
progressBar1.Value = 100;
btnClose.Enabled = true;
btnRead.Enabled = true;
btnOpen.Enabled = false;
}
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("UnauthorizedAccessException");
}
}
private void btnClose_Click(object sender, EventArgs e)
{
serialPort1.Close();
progressBar1.Value = 0;
btnRead.Enabled = false;
btnClose.Enabled = false;
btnOpen.Enabled = true;
}
and when i Click button Read the serialport always give me "OK OK OK", why no have Message go in ? any problem my AT Command ? or something ?
Related
I want to connect to the wifi network opened from esp32 via c# program and view the data sent from esp32. I was doing this project before using arduino via serialport, but I need to do it with local wifi network and I couldn't find the necessary codes to connect to wifi network. Can you help me.
I made a small program using the BMP180 sensor. I show data in C# by transferring data via Arduino and C# program. In this program, I want to transfer data by using ESP32 and connecting to the wifi network (The ones shown in the picture are a program I made over serialport using arduino.
public partial class Form1 : Form
{
int line = 1;
int column = 1;
int lineNumber = 1;
public Form1()
{
InitializeComponent();
}
private string data;
private void Form1_Load(object sender, EventArgs e)
{
string[] ports = SerialPort.GetPortNames();
foreach (string port in ports)
{
comboBox1.Items.Add(port);
}
chart1.ChartAreas[0].AxisY.Minimum = 0;
chart1.ChartAreas[0].AxisY.Maximum = 1000;
chart1.ChartAreas[0].AxisY.Interval = 100;
chart1.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss";
chart2.ChartAreas[0].AxisY.Minimum = 0;
chart2.ChartAreas[0].AxisY.Maximum = 100;
chart2.ChartAreas[0].AxisY.Interval = 10;
chart2.ChartAreas[0].AxisX.MajorGrid.LineWidth = 0;
chart2.ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss";
serialPort1.DataReceived += new SerialDataReceivedEventHandler(SerialPort_DataReceived);
}
private void SerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
data = serialPort1.ReadLine();
this.Invoke(new EventHandler(displaydata));
}
private void displaydata(object sender, EventArgs e)
{
DateTime myDateValue = DateTime.Now;
textBox3.Text = myDateValue.ToString();
string[] value = data.Split(',');
textBox1.Text = value[0];
textBox2.Text = value[1];
string pressure = Convert.ToString(value[0]);
string temperature = Convert.ToString(value[1]);
this.chart1.Series[0].Points.AddXY(myDateValue.ToString("HH:mm:ss"), pressure); //zaman ve basınç değerini eksenlere ata
this.chart2.Series[0].Points.AddXY(myDateValue.ToString("HH:mm:ss"), temperature); //zaman ve sıcaklık değerini eksenlere ata
line = dataGridView1.Rows.Add();
dataGridView1.Rows[line].Cells[0].Value = lineNumber;
dataGridView1.Rows[line].Cells[1].Value = pressure;
dataGridView1.Rows[line].Cells[2].Value = temperature;
dataGridView1.Rows[line].Cells[3].Value = myDateValue.ToShortDateString();
dataGridView1.Rows[line].Cells[4].Value = myDateValue.ToLongTimeString();
line++;
lineNumber++;
}
private void button1_Click(object sender, EventArgs e)
{
try
{
serialPort1.PortName = comboBox1.Text;
serialPort1.BaudRate = 9600;
serialPort1.Open();
button1.Enabled = false;
button2.Enabled=true;
label1.Text = "Connected.";
label1.ForeColor = Color.Green;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ("Error:"));
}
}
private void button2_Click(object sender, EventArgs e)
{
try
{
serialPort1.Close();
button1.Enabled = true;
button2.Enabled = false;
label1.Text = "Disconnected";
label1.ForeColor = Color.Red;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ("Error:"));
}
}
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
if (serialPort1.IsOpen) serialPort1.Close();
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Interval = 1000;
}
private void button3_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Excel.Application uyg = new Microsoft.Office.Interop.Excel.Application();
uyg.Visible = true;
Microsoft.Office.Interop.Excel.Workbook kitap = uyg.Workbooks.Add(System.Reflection.Missing.Value);
Microsoft.Office.Interop.Excel.Worksheet sheet1 = (Microsoft.Office.Interop.Excel.Worksheet)kitap.Sheets[1];
for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Office.Interop.Excel.Range)sheet1.Cells[1, i + 1];
myRange.Value2 = dataGridView1.Columns[i].HeaderText;
}
for (int i = 0; i < dataGridView1.Columns.Count; i++)
{
for (int j = 0; j < dataGridView1.Rows.Count; j++)
{
Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Office.Interop.Excel.Range)sheet1.Cells[j + 2, i + 1];
myRange.Value2 = dataGridView1[i, j].Value;
}
}
}
}
}
I think the best option is to use TCP/IP socket connection.
For the ESP32 there are some libraries like:
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/lwip.html
And from C#:
https://learn.microsoft.com/en-us/dotnet/framework/network-programming/using-tcp-services
I'm right now trying to read sensor data through USB-RS485 converter and utilizing the EasyModbus.dll in C#.
However, I've kept receiving CRC checked failed at the ReadHoldingRegister part. The connection and reading part is shown below.
I've already done lots of research but still can't solve the issue. Can anyone help me with this?
The CRC checked failed will occur at
int[] Read = modbusClient.ReadHoldingRegisters(179, 6);
The FT300 Modbus Setting is also shown below:
Image is stolen from this manual, page 34
void getavailableports() // get available COM
{
comboBox1.Items.Clear();
string[] ports = SerialPort.GetPortNames();
comboBox1.Items.AddRange(ports);
}
private void comboBox1_MouseClick(object sender, MouseEventArgs e) //let user choose COM
{
getavailableports();
}
private void Start_Click(object sender, EventArgs e) // Start button being pressed
{
try
{
Invoke(new EventHandler(ChangeColor));
//FT300Port.PortName = comboBox1.Text;
//.BaudRate = Convert.ToInt32(BaudRate.Text);
//FT300Port.Open();
modbusClient.UnitIdentifier = 9; // default slaveID = 1
modbusClient.Baudrate = Convert.ToInt32(BaudRate.Text); // default baudrate = 9600
modbusClient.Parity = System.IO.Ports.Parity.None;
modbusClient.StopBits = System.IO.Ports.StopBits.One;
modbusClient.ConnectionTimeout = 500;
modbusClient.Connect();
lb_status.Text = "Connected";
timer_Modbus.Enabled = true;
}
catch(Exception ex)
{
lb_status.Text = ex.ToString();
throw;
}
}
private void ChangeColor(object sender, EventArgs e)
{
Start.Text = "Streaming";
Start.BackColor = Color.Red;
}
private void Disconnect_Click(object sender, EventArgs e)
{
modbusClient.Disconnect();
Start.Text = "Start";
Start.BackColor = Color.DarkGray;
lb_status.Text = "Disconnected";
timer_Modbus.Enabled = false;
}
private void timer_Modbus_Tick(object sender, EventArgs e)
{
timer_Modbus.Enabled = false;
//modbusClient.WriteMultipleCoils(179, new bool[] { true, true, true, true, true, true});
//Write Coils starting with Address 180
//bool[] readCoils = modbusClient.ReadCoils(179, 6);
**int[] Read = modbusClient.ReadHoldingRegisters(179, 6);**
/*textBox1.Text = Convert.ToString(Read[0]);
textBox2.Text = Convert.ToString(Read[1]);
textBox3.Text = Convert.ToString(Read[2]);
textBox4.Text = Convert.ToString(Read[3]);
textBox5.Text = Convert.ToString(Read[4]);
textBox6.Text = Convert.ToString(Read[5]);*/
timer_Modbus.Enabled = true;
}
The following code reads port data and writes the data into a textbox with timestemp once it differs from the previous one. Afterwards I can save the data to a textfile.
Instead of writing it into a textbox and then save it to text file per button, I would like it to auto append to the text file every x seconds (lets say 10). By reading through other questions I got some ideas but was not really able to execute them.
Anyone can help?
public partial class Form1 : Form
{
private SerialPort myport;
private DateTime datetime;
private string in_data;
private string in_data_old = "";
public Form1()
{
InitializeComponent();
}
private void start_btn_Click(object sender, EventArgs e)
{
myport = new SerialPort();
myport.BaudRate = 9600;
myport.PortName = port_name_tb.Text;
myport.Parity = Parity.None;
myport.DataBits = 8;
myport.StopBits = StopBits.One;
myport.DataReceived += myport_DataReceived;
try
{
myport.Open();
data_tb.Text = "";
}
catch(Exception ex) {
MessageBox.Show(ex.Message, "Error");
}
}
void myport_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
in_data = myport.ReadLine();
if (in_data != in_data_old)
{
this.Invoke(new EventHandler(displaydata_event));
}
in_data_old = in_data;
}
private void displaydata_event(object sender, EventArgs e)
{
datetime = DateTime.Now;
string time = datetime.Year+ "." +datetime.Month+ "." + datetime.Day + " " + datetime.Hour+ ":" +datetime.Minute+ ":" +datetime.Second;
data_tb.AppendText(time + "\t\t\t\t\t" + in_data+"\n");
}
private void stop_btn_Click(object sender, EventArgs e)
{
try
{
myport.Close();
}
catch (Exception ex2)
{
MessageBox.Show(ex2.Message, "Error");
}
}
private void save_btn_Click(object sender, EventArgs e)
{
try
{
string pathfile = #"C:\Users\xy\Desktop\DATA\";
string filename = "light_data.txt";
System.IO.File.AppendAllText(pathfile + filename, data_tb.Text);
MessageBox.Show("Data has been saved to "+pathfile, "Save File");
}
catch(Exception ex3)
{
MessageBox.Show(ex3.Message, "Error");
}
}
}
Add a Timer , you can find it on the toolbox and you can set it's interval for any timer you would like and add your btn click functionality there example :
private void timer1_Tick(object sender, EventArgs e)
{
myport = new SerialPort();
myport.BaudRate = 9600;
myport.PortName = port_name_tb.Text;
myport.Parity = Parity.None;
myport.DataBits = 8;
myport.StopBits = StopBits.One;
myport.DataReceived += myport_DataReceived;
try
{
myport.Open();
data_tb.Text = "";
}
catch(Exception ex) {
MessageBox.Show(ex.Message, "Error");
}
}
Tool Image Winform
I am working on a tool that connected to my Bluetooth receiver and scan and get MAC address of BLE devices. So far I can scan and have the mac address continuously display in textbox. I am having problem with filtering MAC address?(Our assigned MAC address 88 99 66 55 4X XX the last 12 bit is free to use). How can I filter this while scanning and put it in Listbox or Textbox for later use.
public SerialPort serialport;
private bool buttonWasClicked = false;
public Form1()
{
InitializeComponent();
foreach (string s in SerialPort.GetPortNames())
{
cmPort.Items.Add(s);
}
}
public void serialport_connect(String port, int baudrate)
{
DateTime dt = DateTime.Now;
String dtn = dt.ToShortTimeString();
serialport = new SerialPort(port, baudrate);
try
{
serialport.Open();
textBox1.AppendText(" OPEN " + "[" + dtn + "] " + " Port Opened: Connected\n");
// Event Handler
serialport.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error");
}
}
private void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
DateTime dt = DateTime.Now;
String dtn = dt.ToShortTimeString();
//TextBox.CheckForIllegalCrossThreadCalls = false;
if (buttonWasClicked == true)
{
ThreadSafeDelegate(delegate { ScanList.Items.Add(serialport.ReadExisting()); });
//ThreadSafeDelegate(delegate { textBox3.Text += "\r\n"; });
}
else
{
ThreadSafeDelegate(delegate { textBox1.AppendText(serialport.ReadExisting()); });
ThreadSafeDelegate(delegate { textBox1.Text += "\r\n"; });
//textBox1.AppendText(serialport.ReadExisting());
//textBox1.Text += "\r\n";
}
}
private void button1_Click(object sender, EventArgs e)
{
byte[] msg = ASCIIEncoding.ASCII.GetBytes(textBox2.Text + "\0");
serialport.Write(msg, 0, msg.Length);
}
private void button2_Click(object sender, EventArgs e)
{
String port = cmPort.Text;
int baudrate = Convert.ToInt32(cmBaud.Text);
//Parity parity = (Parity)Enum.Parse(typeof(Parity), cmbparity.Text);
//int databits = Convert.ToInt32(cmbdatabits.Text);
//StopBits stopbits = (StopBits)Enum.Parse(typeof(StopBits), cmbstopbits.Text);
button3.Enabled = true;
serialport_connect(port, baudrate);
}
private void button3_Click(object sender, EventArgs e)
{
DateTime dt = DateTime.Now;
String dtn = dt.ToShortTimeString();
if (serialport.IsOpen)
{
serialport.Close();
button3.Enabled = false;
button2.Enabled = true;
textBox1.AppendText("[" + dtn + "] " + "Port Close: Disconnected\n");
}
}
private void btnClear_Click(object sender, EventArgs e)
{
textBox1.Text = "";
}
private void ThreadSafeDelegate(MethodInvoker method)
{
if (InvokeRequired)
BeginInvoke(method);
else
method.Invoke();
}
private void Scan_Click(object sender, EventArgs e)
{
buttonWasClicked = true;
byte[] msg = ASCIIEncoding.ASCII.GetBytes( "SNS10" + "\0");
serialport.Write(msg, 0, msg.Length);
}
}
}
We are just making a small quiz with TCP server. We can connect one client to the server but with multiple the server crashes. Ignore the dutch in it.
It can be that there are some non-logic things in it cause we have been playing with it for some hours.
Our code for the server:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Diagnostics;
namespace Simpele_Server
{
class Program
{
const int portNr = 2000;
static void Main(string[] args)
{
Program obj = new Program();
string antwoord = "";
string client1Ant = "";
string client2Ant = "";
string client3ant = "";
System.Net.IPAddress localAddress = System.Net.IPAddress.Parse("10.145.4.43");
//Luister op het eigen IP-adres: 127.0.0.1 (Loop back adres)
TcpListener mijnListener = new TcpListener(localAddress, portNr);
mijnListener.Start();
Console.WriteLine("\n Wachten op verbinding...\n");
while (true)
{
//Aanvaard het binnenkomende verzoek
TcpClient eenClient = mijnListener.AcceptTcpClient();
//Gebruik een 'NetworkStream object' om gegevens te verzenden en te ontvangen
NetworkStream ns = eenClient.GetStream();
byte[] data = new byte[eenClient.ReceiveBufferSize];
//Lees de binnenkomende 'stream' --> Read() is een 'blocking call'
int numBytesRead = ns.Read(data, 0,System.Convert.ToInt32(eenClient.ReceiveBufferSize));
antwoord = Encoding.ASCII.GetString(data, 0, numBytesRead);
if (antwoord.Substring(0, 8).Equals("Client1:"))
{
client1Ant = antwoord;
Console.WriteLine(obj.ControleerAntwoorden1(client1Ant));
}
if (antwoord.Substring(0, 8).Equals("Client2:"))
{
client1Ant = antwoord;
Console.WriteLine(obj.ControleerAntwoorden2(client2Ant));
}
if (antwoord.Substring(0, 8).Equals("Client3:"))
{
client1Ant = antwoord;
Console.WriteLine(obj.ControleerAntwoorden3(client3ant));
}
//Beeld de ontvangen data af
Console.WriteLine("Ontvangen: " + antwoord);
}
//Voorkom onmiddellijk sluiten van het venster
Console.ReadLine();
}
private int ControleerAntwoorden1(string antwoord)
{
int punten = 0;
string antw;
antw = antwoord.Replace("Client1:", "");
//antw = antwoord.Replace("Client2:", "");
//antw = antwoord.Replace("Client3:", "");
Console.WriteLine(antw);
string ant1 = antw.Substring(0, 1);
string ant2 = antw.Substring(1, 1);
string ant3 = antw.Substring(2, 1);
string ant4 = antw.Substring(3, 1);
if (ant1.Equals("1"))
punten++;
if (ant2.Equals("2"))
punten++;
if (ant3.Equals("3"))
punten++;
if (ant4.Equals("4"))
punten++;
return punten;
}
private int ControleerAntwoorden2(string antwoord)
{
int punten = 0;
string antw;
//antw = antwoord.Replace("Client1:", "");
antw = antwoord.Replace("Client2:", "");
//antw = antwoord.Replace("Client3:", "");
Console.WriteLine(antw);
string ant1 = antw.Substring(0, 1);
string ant2 = antw.Substring(1, 1);
string ant3 = antw.Substring(2, 1);
string ant4 = antw.Substring(3, 1);
if (ant1.Equals("1"))
punten++;
if (ant2.Equals("2"))
punten++;
if (ant3.Equals("3"))
punten++;
if (ant4.Equals("4"))
punten++;
return punten;
}
private int ControleerAntwoorden3(string antwoord)
{
int punten = 0;
string antw;
//antw = antwoord.Replace("Client1:", "");
//antw = antwoord.Replace("Client2:", "");
antw = antwoord.Replace("Client3:", "");
Console.WriteLine(antw);
string ant1 = antw.Substring(0, 1);
string ant2 = antw.Substring(1, 1);
string ant3 = antw.Substring(2, 1);
string ant4 = antw.Substring(3, 1);
if (ant1.Equals("1"))
punten++;
if (ant2.Equals("2"))
punten++;
if (ant3.Equals("3"))
punten++;
if (ant4.Equals("4"))
punten++;
return punten;
}
}
}
Our client:
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.Net.Sockets;
namespace client
{
public partial class Form1 : Form
{
const int poortNr = 2000;
//string ipadres = "127.0.0.1";
string ipadres = "10.145.4.43";
string strRead = null;
int intBytesRead;
string[] vragen = { "1. In welk jaar is 9/11 gebeurt?" + Environment.NewLine + " A = 2001" + Environment.NewLine + " B = 2000 " + Environment.NewLine + " C = 1999" + Environment.NewLine + " D = 1998",
"2. Welke kleur heeft een wolk?" + Environment.NewLine + " A = Blauw " + Environment.NewLine + " B = Groen " + Environment.NewLine + " C = Wit " + Environment.NewLine + " D = geel",
"3. Leeft Steve Jobs nog? " + Environment.NewLine + " A = Nee " + Environment.NewLine + " B = Ja " + Environment.NewLine + " C = Steve jobs heeft nooit bestaan " + Environment.NewLine + " D = test",
"4. test"};
string antwoorden = "";
int counter;
int aantalcounter = 2;
int vraagnr = 0;
TcpClient mijnClient = new TcpClient();
private void startTimer()
{
counter = aantalcounter;
timer1.Start();
timer1.Interval = 1000;
}
private void resetTimer()
{
counter = aantalcounter;
timer1.Stop();
timer1.Start();
}
private void stopTimer()
{
timer1.Stop();
}
public NetworkStream getNS()
{
//networkstream
NetworkStream mijnNS = mijnClient.GetStream();
return mijnNS;
}
public void disableRadiobuttons()
{
radioButton1.Enabled = false;
radioButton2.Enabled = false;
radioButton3.Enabled = false;
radioButton4.Enabled = false;
}
public void uncheckRadiobuttons()
{
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
radioButton4.Checked = false;
}
//verzend data naar server
public void verzendData(string tekst)
{
byte[] aDataTeVersturen = Encoding.ASCII.GetBytes(tekst);
getNS().Write(aDataTeVersturen, 0, aDataTeVersturen.Length);
}
//zoek selected antwoord
public string getAntwoord()
{
string qsdf = "Client1: ";
string answer = "";
if (radioButton1.Checked == true)
{
answer = "1";
}
if (radioButton2.Checked == true)
{
answer = "2";
}
if (radioButton3.Checked == true)
{
answer = "3";
}
if (radioButton4.Checked == true)
{
answer = "4";
}
if (radioButton1.Checked == false && radioButton2.Checked == false && radioButton3.Checked == false && radioButton4.Checked == false)
{
answer = "0"; //geen antwoord
}
qsdf += answer;
return qsdf;
}
//alle antwoorden opslaan in lange string
public void opslaanAntwoorden(string antwoord)
{
antwoorden += antwoord;
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
txtVraag.Text = vragen[vraagnr];
startTimer();
try
{
mijnClient.Connect(ipadres, poortNr);
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private void btnVerbreek_Click(object sender, EventArgs e)
{
getNS().Close();
mijnClient.Close();
Application.Exit();
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void txtAntwoord_TextChanged(object sender, EventArgs e)
{
}
private void btnOntvang_Click(object sender, EventArgs e)
{
//data van server krijgen
byte[] aDataOntvangen = new byte[Convert.ToInt32(mijnClient.ReceiveBufferSize)];
intBytesRead = getNS().Read(aDataOntvangen, 0, Convert.ToInt32(mijnClient.ReceiveBufferSize));
strRead = Encoding.ASCII.GetString(aDataOntvangen, 0, intBytesRead);
}
private void groupBox1_Enter(object sender, EventArgs e)
{
}
private void txtVraag_TextChanged(object sender, EventArgs e)
{
}
private void timer1_Tick_1(object sender, EventArgs e)
{
txtCount.Text = counter.ToString();
counter--;
if (counter == -1)
{
resetTimer();
startTimer();
opslaanAntwoorden(getAntwoord()); //antwoorden opslaan in 1 lange string
if (vraagnr != vragen.Length-1)
{
txtVraag.Text = vragen[vraagnr + 1];
volgendeVraag();
uncheckRadiobuttons();
}
else
{
verzendData(antwoorden); //zend alle antwoorden (einde van quiz)
txtVraag.Text = "Einde van quiz";
uncheckRadiobuttons();
disableRadiobuttons();
//timer op 0 + stoppen
stopTimer();
counter = 0;
txtCount.Text = counter.ToString();
}
}
}
private void volgendeVraag()
{
vraagnr++;
}
private void label2_Click(object sender, EventArgs e)
{
}
private void radioButton4_CheckedChanged(object sender, EventArgs e)
{
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
}
private void lblCount_Click(object sender, EventArgs e)
{
}
}
}