開發平台(Platform): (Ex: Win10, Linux, ...)
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
開發平台(Platform): (Ex: Win10, Linux, ...)
Win7
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
VC 2013
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
參考 https://www.teuniz.net/RS-232/
RS232.c, RS232.h
問題(Question):
我要使用RS232連接我的裝置
裝置是一台Sony的攝像機(Visca協定),可以控制他的底座轉向。
目前只能確認有開始使用COM1。
不知道問題是在
1.給指令的方法有問題
2.根本沒連接到攝像機
預期的正確結果(Expected Output):
我傳送一段指令 例如:81010601010103FF
他會回傳我:9041FF9051FF
錯誤結果(Wrong Output):
輸入指令,設備確沒有反應。
程式碼(Code):(請善用置底文網頁, 記得排版,禁止使用圖檔)
#include <stdlib.h>
#include <stdio.h>
#include <Windows.h>
#include "rs232.h"
int main()
{
int i, n,
cport_nr=0, /* COM1 = 0 */
bdrate=9600; /* baud */
unsigned char buf[4096];
char mode[]={'8','N','1',0};
if(RS232_OpenComport(cport_nr, bdrate, mode))
{
printf("Can not open comport\n");
return(0);
}
char s[100];
scanf("%s", s);
if( s != NULL )
{
RS232_cputs(cport_nr, s);
}
n = RS232_PollComport(cport_nr, buf, 4095);
if(n > 0)
{
buf[n] = 0; /* always put a "null" at the end of a string! *
/
printf("%s", (char *)buf);
}
RS232_CloseComport(cport_nr);
return(0);
}
希望有使用過這library的能指導我,十分謝謝。