Code Monkey home page Code Monkey logo

rs232_c's Introduction

RS232_C

test C RS232 library, reference, https://www.teuniz.net/RS-232/

update, Test_DTR_RTS.exe and main2.c compile_main2.c Test_DTR_RTS.JPG

testing, done
win10 x64
modified rs232.c
changed COM port array, 17 items,
1st item is dummy for index 0, so index 1 = "\\.\.COM1" and so on
MinGW used

//--------------------------- main.c
//JUL-30-2011, xiaolaba
//last update 2018-NOV-17, xiaolaba

// 2018-NOV-17, library has been update, https://www.teuniz.net/RS-232/
// November 22, 2017 new version

// all function named RS232_ as prefix
// fix the mian.c source code here, fucntion call add prefix "RS232_"
// MODE change from "N81" ro "8N1" 
// upload to Github, include library source code as original author license GNU GPL.

// how to compile
// install minGW, http://sourceforge.net/projects/mingw/files/
// Win10,
// run dosbox.bat,
// command line, set path=c:\MinGW\bin;%path%
// or command line, set_path.bat
// command line, compile.bat
// 
// Gcc, 沒有GDB 除錯資料的編譯 
//   gcc -static -o RS232.exe main.c RS232_xiaolaba.c
// 
//用G++, 包含GDB 除錯資料的編譯 g
//   ++ -g -static -o RS232.exe main.c RS232_xiaolaba.c


 
#include <stdio.h> //wordpress 自動去除 < > 及內容, 解決辦法, 前後加空格
#include <stdlib.h>
 
#include "rs232.h" //wordpress 自動轉換雙引號為 半角符號, 無法解決
//原因參考以下
//http://farlee.info/archives/wordpress-format-quote-mark.html
 
//測試用, 打開 com port, 發送3byte資料, 關閉 com port
 
int main()
{
//int RS232_OpenComport(int comport_number, int baudrate, const char * mode)

//RS232_OpenComport(4, 9600, "N81"); //win32/ win64 底下有問題, 需要改library

//** change com port number array with one the first dummy element, or write COM#-1
//** Windows COM PORT number is COM1,COM2, index is -1
//  RS232_OpenComport(6-1, 115200, "8N1"); //win32/ win64 底下有問題, 需要改library

  printf("wanna open COM6\n");
  RS232_OpenComport(6, 115200, "8N1"); //win32/ win64 底下有問題, 需要改library

  RS232_SendByte(3, 'S');
  char i;
 
  for(i=0x30;i<0x40;i++){
    RS232_SendByte(3, i);
  }
 
  RS232_CloseComport(4);

}
 
//--------------------------- main.c

rs232_c's People

Contributors

xiaolaba avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.