我将如何在C#中生成触发器更新? [英] how i will generate trigger updates in c#?

查看:104
本文介绍了我将如何在C#中生成触发器更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


您能否告诉我,我将如何生成触发器更新,以持续监控通过通讯端口来自传感器的数据,然后使用GSM模块将该数据发送到移动设备?
视觉工作室2010


谢谢Ismail khan

解决方案

您可以这样做:

 // 串行中继-Arduino将修补
// 计算机与GPRS Shield之间的串行链接
// 以19200 bps 8-N-1的速率
// 计算机已连接到硬件UART 
//  GPRS Shield已连接到软件UART 

#include< SoftwareSerial.h>

SoftwareSerial GPRS( 7  8 );
未签名的 char 缓冲区[ 64 ]; // 用于通过串行端口接收数据的缓冲区阵列
 int  count =  0 ; // 缓冲区数组的计数器
无效 setup()
{
  GPRS.begin( 19200 ); //  GPRS波特率
  Serial.begin( 19200 ); //  Arduino波特率的串行端口.

}

无效 loop()
{
  如果(GPRS.available())// 如果是日期从软件串行端口==>数据来自gprs shield 
  {
    同时(GPRS.available())// 读取数据放入char数组
    {
      buffer [count ++] = GPRS.read(); // 将数据写入数组
      如果(计数==  64 ) break  ;
  }
    Serial.write(buffer,count); // 如果没有数据传输结束,则将缓冲区写入硬件串行端口
    clearBufferArray(); // 调用clearBufferArray函数从阵列中清除存储的数据
    count =  0 ; // 将while循环的计数器设置为零


  }
  如果(Serial.available())// 如果有数据在硬件串行端口==>上可用数据来自PC或笔记本电脑
    GPRS.write(Serial.read()); // 将其写入GPRS防护板
}
 void  clearBufferArray()// 函数清除缓冲区数组
{
   for ( int  i =  0 ; i< ; count; i ++)
    {buffer [i] = NULL;} // 使用NULL命令清除数组的所有索引
} 


hi
will you tell me please how i will generate trigger updates to continuously monitoring the data coming from sensor through comm port and then send this data to mobile using GSM module??
visual studio 2010


thanks Ismail khan

解决方案

You can do like this :

//Serial Relay - Arduino will patch a
//serial link between the computer and the GPRS Shield
//at 19200 bps 8-N-1
//Computer is connected to Hardware UART
//GPRS Shield is connected to the Software UART

#include <SoftwareSerial.h>

SoftwareSerial GPRS(7, 8);
unsigned char buffer[64]; // buffer array for data recieve over serial port
int count=0;     // counter for buffer array
void setup()
{
  GPRS.begin(19200);               // the GPRS baud rate
  Serial.begin(19200);             // the Serial port of Arduino baud rate.

}

void loop()
{
  if (GPRS.available())              // if date is comming from softwareserial port ==> data is comming from gprs shield
  {
    while(GPRS.available())          // reading data into char array
    {
      buffer[count++]=GPRS.read();     // writing data into array
      if(count == 64)break;
  }
    Serial.write(buffer,count);            // if no data transmission ends, write buffer to hardware serial port
    clearBufferArray();              // call clearBufferArray function to clear the storaged data from the array
    count = 0;                       // set counter of while loop to zero


  }
  if (Serial.available())            // if data is available on hardwareserial port ==> data is comming from PC or notebook
    GPRS.write(Serial.read());       // write it to the GPRS shield
}
void clearBufferArray()              // function to clear buffer array
{
  for (int i=0; i<count;i++)
    { buffer[i]=NULL;}                  // clear all index of array with command NULL
}


这篇关于我将如何在C#中生成触发器更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆