RS232 for USB/notes
版主: bryanchang、digdog、謝孟叡
RS232 for USB/notes
大家好,我是剛從 windows 一族投奔 MAC 的新人使用者
因為工作上的需要,我需要隨時準備有 RS232 來使用 ( Network device console )
之前在 XP 的環境上,很容易可以買到 USB<-->RS232 的轉接頭
可是在 MAC OS 的環境中似乎很難找到 , 可以請問有人知道可以上那邊買到嗎?
第二個問題,ibm notes 有沒有 for MACOS 的版本阿
因為工作上的需要,我需要隨時準備有 RS232 來使用 ( Network device console )
之前在 XP 的環境上,很容易可以買到 USB<-->RS232 的轉接頭
可是在 MAC OS 的環境中似乎很難找到 , 可以請問有人知道可以上那邊買到嗎?
第二個問題,ibm notes 有沒有 for MACOS 的版本阿
Re: RS232 for USB/notes
引述之前魔戒大大回覆Barocde問題的內容:bluebaby 寫:大家好,我是剛從 windows 一族投奔 MAC 的新人使用者
因為工作上的需要,我需要隨時準備有 RS232 來使用 ( Network device console )
之前在 XP 的環境上,很容易可以買到 USB<-->RS232 的轉接頭
可是在 MAC OS 的環境中似乎很難找到 , 可以請問有人知道可以上那邊買到嗎?
第二個問題,ibm notes 有沒有 for MACOS 的版本阿
1. RS232:可能已經不多見了。買一條 USB-RS232 轉接線,然後開 Serial Port 就可以抓到。光華一條 300 元的 Prolific 晶片轉接線就有支援 Mac,不過 Driver 要上網抓。
yes, he is.
Re: RS232 for USB/notes
第二個問題bluebaby 寫:大家好,我是剛從 windows 一族投奔 MAC 的新人使用者
因為工作上的需要,我需要隨時準備有 RS232 來使用 ( Network device console )
之前在 XP 的環境上,很容易可以買到 USB<-->RS232 的轉接頭
可是在 MAC OS 的環境中似乎很難找到 , 可以請問有人知道可以上那邊買到嗎?
第二個問題,ibm notes 有沒有 for MACOS 的版本阿
IBM Notes Client 嗎?有,目前在10.4.2下使用無誤
只是中文要花點功夫才能正確顯示
一字曰心
Re: RS232 for USB/notes
喔??不知道方不方便給點指示??mokap 寫:第二個問題bluebaby 寫:大家好,我是剛從 windows 一族投奔 MAC 的新人使用者
因為工作上的需要,我需要隨時準備有 RS232 來使用 ( Network device console )
之前在 XP 的環境上,很容易可以買到 USB<-->RS232 的轉接頭
可是在 MAC OS 的環境中似乎很難找到 , 可以請問有人知道可以上那邊買到嗎?
第二個問題,ibm notes 有沒有 for MACOS 的版本阿
IBM Notes Client 嗎?有,目前在10.4.2下使用無誤
只是中文要花點功夫才能正確顯示
小弟以前也遇過這個問題
雖然現在不需要用到Notes,不過還是蠻想知道解法的
是Big-5跟Unicode的問題嗎??
Re: RS232 for USB/notes
請參考友站 OIKOS 之前的討論。jamesjan 寫:喔??不知道方不方便給點指示??mokap 寫:第二個問題bluebaby 寫:大家好,我是剛從 windows 一族投奔 MAC 的新人使用者
因為工作上的需要,我需要隨時準備有 RS232 來使用 ( Network device console )
之前在 XP 的環境上,很容易可以買到 USB<-->RS232 的轉接頭
可是在 MAC OS 的環境中似乎很難找到 , 可以請問有人知道可以上那邊買到嗎?
第二個問題,ibm notes 有沒有 for MACOS 的版本阿
IBM Notes Client 嗎?有,目前在10.4.2下使用無誤
只是中文要花點功夫才能正確顯示
小弟以前也遇過這個問題
雖然現在不需要用到Notes,不過還是蠻想知道解法的
是Big-5跟Unicode的問題嗎??
http://ubb.frostyplace.com.tw/viewtopic.php?t=14490
Re: RS232 for USB/notes
我應該已經找到了適合的 cable 而且已經成功安裝了shen 寫:引述之前魔戒大大回覆Barocde問題的內容:bluebaby 寫:大家好,我是剛從 windows 一族投奔 MAC 的新人使用者
因為工作上的需要,我需要隨時準備有 RS232 來使用 ( Network device console )
之前在 XP 的環境上,很容易可以買到 USB<-->RS232 的轉接頭
可是在 MAC OS 的環境中似乎很難找到 , 可以請問有人知道可以上那邊買到嗎?
第二個問題,ibm notes 有沒有 for MACOS 的版本阿
1. RS232:可能已經不多見了。買一條 USB-RS232 轉接線,然後開 Serial Port 就可以抓到。光華一條 300 元的 Prolific 晶片轉接線就有支援 Mac,不過 Driver 要上網抓。
想請問一下, for mac 有沒有比較適合的 console 的軟體 ?
and , serial port 要怎麼打開呢 ? thanks
Re: RS232 for USB/notes
終端機有老字號的 ZTerm,在下是覺得不大好用啦,所以都自己寫。bluebaby 寫:我應該已經找到了適合的 cable 而且已經成功安裝了
想請問一下, for mac 有沒有比較適合的 console 的軟體 ?
and , serial port 要怎麼打開呢 ? thanks
開 Serial Port 很簡單,這是在下的標準程式碼:
代碼: 選擇全部
#include <fcntl.h>
#include <termios.h>
static struct termios rsNewTerm;
static struct termios rsOrigTerm;
int serial_open(char *path, speed_t speed) {
int rs232FD;
rs232FD = open(path, O_RDWR|O_NOCTTY|O_NONBLOCK);
if(rs232FD < 0) {
return -1;
}
tcgetattr(rs232FD,&(rsOrigTerm));
memcpy(&(rsNewTerm), &(rsOrigTerm), sizeof(rsOrigTerm));
rsNewTerm.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
rsNewTerm.c_cflag &= ~(CSIZE | PARENB | CSTOPB);
rsNewTerm.c_cflag |= HUPCL | CLOCAL | CREAD | CRTSCTS | CS8;
rsNewTerm.c_oflag &= ~(OPOST);
rsNewTerm.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON | IXOFF | IXANY);
rsNewTerm.c_cc[VMIN] = 1;
rsNewTerm.c_cc[VTIME] = 0;
cfsetospeed(&(rsNewTerm), speed);
cfsetispeed(&(rsNewTerm), speed);
tcsetattr(rs232FD, TCSANOW, &(rsNewTerm));
return rs232FD;
}
void serial_close(int rs232FD) {
tcsetattr(rs232FD, TCSANOW, &(rsOrigTerm));
close(rs232FD);
}
如果你懶得自己寫,也有 Open Source 的 CLI 程式可用。在下偏好用 microcom 這個程式,不過他的原始 Distribution 有點問題無法在 Mac 上正確 Compile。在下把他的 Code 拿來修改編譯,發佈 Mac OS X 的 Binary 版本。你可以到這裡下載:
http://homepage.mac.com/ulyssesric/warehouse/
ash nazg durbatuluk, ash nazg gimbatul,
ash nazg thrakatuluk agh burzum-ishi krimpatul.
ash nazg thrakatuluk agh burzum-ishi krimpatul.
請問個笨問題,請問 serial port 使用前要開,那用完是不是得關??
我有下載microcom 來看了,不過執行後
Last login: Mon Nov 5 16:59:29 on ttys000
/Users/PonyMa/Desktop/microcom/microcom ; exit;
ponymas-imac:~ PonyMa$ /Users/PonyMa/Desktop/microcom/microcom ; exit;
Try /dev/ttyS0
/dev/ttyS0 not found
Try /dev/ttyS1
/dev/ttyS1 not found
Try /dev/ttyS2
/dev/ttyS2 not found
Try /dev/ttyS3
/dev/ttyS3 not found
Usage: microcom [options]
[options] include:
-Ddevfile use the specified serial port device;
if a port is not provided, microcom
will try to autodetect a modem
example: -D/dev/ttyS3
-S run script from script.scr (default)
-Sscrfile run script from scrfile
microcom provides session logging in microcom.log file
Exitcode 1 - no device found
logout
[程序完成]
就顯示這些,這代表什麼意思,該怎用呢??
PS: 我使用ATEN 的 UC-232A by OSX10.4 driver on OSX10.4
我有下載microcom 來看了,不過執行後
Last login: Mon Nov 5 16:59:29 on ttys000
/Users/PonyMa/Desktop/microcom/microcom ; exit;
ponymas-imac:~ PonyMa$ /Users/PonyMa/Desktop/microcom/microcom ; exit;
Try /dev/ttyS0
/dev/ttyS0 not found
Try /dev/ttyS1
/dev/ttyS1 not found
Try /dev/ttyS2
/dev/ttyS2 not found
Try /dev/ttyS3
/dev/ttyS3 not found
Usage: microcom [options]
[options] include:
-Ddevfile use the specified serial port device;
if a port is not provided, microcom
will try to autodetect a modem
example: -D/dev/ttyS3
-S run script from script.scr (default)
-Sscrfile run script from scrfile
microcom provides session logging in microcom.log file
Exitcode 1 - no device found
logout
[程序完成]
就顯示這些,這代表什麼意思,該怎用呢??
PS: 我使用ATEN 的 UC-232A by OSX10.4 driver on OSX10.4
USB to RS232
for Windows 用 Prolific 光華買的相容性較好
for Mac OSX 用 Keyspan USA-19HS 相容性較好,新 Driver V 2.4 原廠測試過,可以和 OSX10.5 Leopard 相容
http://keyspan.custhelp.com/cgi-bin/key ... _faqid=697
for Windows 用 Prolific 光華買的相容性較好
for Mac OSX 用 Keyspan USA-19HS 相容性較好,新 Driver V 2.4 原廠測試過,可以和 OSX10.5 Leopard 相容
http://keyspan.custhelp.com/cgi-bin/key ... _faqid=697
I love OPERA !
首先要安裝 RS232 驅動程式
Keyspan : http://www.keyspan.com/downloads/homepage_pn_usa19.spml
Prolific: http://www.prolific.com.tw/eng/downloads.asp?ID=31
然後找一個 RS232 應用程式來下載資料
如找不到,就需要自己寫一個程式,可到 Apple 網站找到 SerialPortSample.dmg 參考一下,
http://developer.apple.com/samplecode/SerialPortSample/
可以直接用 Cocoa GUI 呼叫它的副程式,很容易的。
Keyspan : http://www.keyspan.com/downloads/homepage_pn_usa19.spml
Prolific: http://www.prolific.com.tw/eng/downloads.asp?ID=31
然後找一個 RS232 應用程式來下載資料
如找不到,就需要自己寫一個程式,可到 Apple 網站找到 SerialPortSample.dmg 參考一下,
http://developer.apple.com/samplecode/SerialPortSample/
可以直接用 Cocoa GUI 呼叫它的副程式,很容易的。
I love OPERA !
不好意思我遇到困難了....
我利用imac G5上用Keyspan來做輸出 , macbook上用Prolific做接收
imac上的code是:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#define BaudRate B38400
#define RS232Path "/dev/cu.KeySerial1"
#define STOP '@'
int main (int argc, const char * argv[])
{
int fd, res;
struct termios oldtio, newtio;
char ch;
static char s1[20];
printf("Start...\n");
fd = open(RS232Path, O_RDWR|O_NOCTTY);
if (fd < 0)
{
perror(RS232Path);
exit(1);
}
printf("Open...\n");
tcgetattr(fd, &oldtio);
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BaudRate|CS8|CLOCAL|CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
printf("Writing...\n");
while(1)
{
while((ch=getchar()) != STOP)
{
s1[0]=ch;
res=write(fd, s1, 1);
}
s1[0]=ch;
s1[1]='\n';
res = write(fd, s1, 2);
break;
}
printf("Close...\n");
close(fd);
tcsetattr(fd, TCSANOW, &oldtio);
return 0;
}
macbook上的code是:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#define BaudRate B38400
#define RS232Path "/dev/cu.usbserial"
#define _POSIX_SOURCE 1
int main (int argc, const char * argv[])
{
int fd, res;
struct termios oldtio, newtio;
char buf[256];
printf("Start...\n");
fd = open(RS232Path, O_RDWR|O_NOCTTY);
if (fd < 0)
{
perror(RS232Path);
exit(1);
}
printf("Open...\n");
tcgetattr(fd, &oldtio);
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BaudRate|CS8|CLOCAL|CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
printf("Reading...\n");
while(1)
{
res = read(fd, buf, 255);
buf[res]=0;
printf("res=%d buf=%s\n", res, buf);
if (buf[0] == '@') break;
}
printf("Close...\n");
close(fd);
tcsetattr(fd, TCSANOW, &oldtio);
return 0;
}
可是我執行出來的時候xcode是可以過的
我在imac上輸入隨便一個數字
我在macbook上卻沒有辦法接收到數字
請問為什麼呢?
感謝不盡
我利用imac G5上用Keyspan來做輸出 , macbook上用Prolific做接收
imac上的code是:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#define BaudRate B38400
#define RS232Path "/dev/cu.KeySerial1"
#define STOP '@'
int main (int argc, const char * argv[])
{
int fd, res;
struct termios oldtio, newtio;
char ch;
static char s1[20];
printf("Start...\n");
fd = open(RS232Path, O_RDWR|O_NOCTTY);
if (fd < 0)
{
perror(RS232Path);
exit(1);
}
printf("Open...\n");
tcgetattr(fd, &oldtio);
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BaudRate|CS8|CLOCAL|CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
printf("Writing...\n");
while(1)
{
while((ch=getchar()) != STOP)
{
s1[0]=ch;
res=write(fd, s1, 1);
}
s1[0]=ch;
s1[1]='\n';
res = write(fd, s1, 2);
break;
}
printf("Close...\n");
close(fd);
tcsetattr(fd, TCSANOW, &oldtio);
return 0;
}
macbook上的code是:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <termios.h>
#include <stdio.h>
#define BaudRate B38400
#define RS232Path "/dev/cu.usbserial"
#define _POSIX_SOURCE 1
int main (int argc, const char * argv[])
{
int fd, res;
struct termios oldtio, newtio;
char buf[256];
printf("Start...\n");
fd = open(RS232Path, O_RDWR|O_NOCTTY);
if (fd < 0)
{
perror(RS232Path);
exit(1);
}
printf("Open...\n");
tcgetattr(fd, &oldtio);
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BaudRate|CS8|CLOCAL|CREAD;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
tcflush(fd, TCIFLUSH);
tcsetattr(fd, TCSANOW, &newtio);
printf("Reading...\n");
while(1)
{
res = read(fd, buf, 255);
buf[res]=0;
printf("res=%d buf=%s\n", res, buf);
if (buf[0] == '@') break;
}
printf("Close...\n");
close(fd);
tcsetattr(fd, TCSANOW, &oldtio);
return 0;
}
可是我執行出來的時候xcode是可以過的
我在imac上輸入隨便一個數字
我在macbook上卻沒有辦法接收到數字
請問為什麼呢?
感謝不盡
謝謝您的指點^^
我後來發現NSRunLoop 可以使用
可以使彩球不會跑出來
可是問題又來了
我想要程式按一個butten可以開始持續做某件事 按另一個butten可以結束這件事
可是我發現按了第一個butten之後我就不能按第二個了
我大概知道是因為我的程式架構有問題 可是我實在是想不出為什麼
我的code:
/* myTest.m*/
#import "myTest.h"
#import "periodicTest.h"
@implementation myTest
- (IBAction)startEvent:(id)sender
{
[testOutlet doloop:YES];
}
- (IBAction)stopEvent:(id)sender
{
[textOutlet doloop:NO];
}
@end
----------------------------------------------------------------------
/* periodicTest.m*/
#import "periodicTest.h"
@implementation periodicTest
- (void)doloop:(BOOL)R
{
double resolution = 1.0;
while (R)
{
NSDate* next = [NSDate dateWithTimeIntervalSinceNow:resolution];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:next];
printf("Do Loop...\n");
}
}
@end
我後來發現NSRunLoop 可以使用
可以使彩球不會跑出來
可是問題又來了
我想要程式按一個butten可以開始持續做某件事 按另一個butten可以結束這件事
可是我發現按了第一個butten之後我就不能按第二個了
我大概知道是因為我的程式架構有問題 可是我實在是想不出為什麼
我的code:
/* myTest.m*/
#import "myTest.h"
#import "periodicTest.h"
@implementation myTest
- (IBAction)startEvent:(id)sender
{
[testOutlet doloop:YES];
}
- (IBAction)stopEvent:(id)sender
{
[textOutlet doloop:NO];
}
@end
----------------------------------------------------------------------
/* periodicTest.m*/
#import "periodicTest.h"
@implementation periodicTest
- (void)doloop:(BOOL)R
{
double resolution = 1.0;
while (R)
{
NSDate* next = [NSDate dateWithTimeIntervalSinceNow:resolution];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:next];
printf("Do Loop...\n");
}
}
@end
invalidate 是可以停掉 Timer 但是有必要這樣做嗎?
把 Timer 來作 doloop 就不會有彩球的問題,如果 TimeInterval 不要設得太短, CPU 的效率也可以很高,
要停掉一個 doloop 只要在 Timeout service routine 設一個 flag 就可以了
Boolean run;
-(void)timeOut:(NSTimer *)aTimer
{
if(!run) return;
( --- your code --- )
}
- (IBAction)start:(id)sender
{
run=TRUE;
}
- (IBAction)stop:(id)sender
{
run=FALSE;
}
把 Timer 來作 doloop 就不會有彩球的問題,如果 TimeInterval 不要設得太短, CPU 的效率也可以很高,
要停掉一個 doloop 只要在 Timeout service routine 設一個 flag 就可以了
Boolean run;
-(void)timeOut:(NSTimer *)aTimer
{
if(!run) return;
( --- your code --- )
}
- (IBAction)start:(id)sender
{
run=TRUE;
}
- (IBAction)stop:(id)sender
{
run=FALSE;
}
I love OPERA !