X-Spam-Check-By: sourceware.org MIME-Version: 1.0 From: andyburgess To: Eric Blake Cc: cygwin AT cygwin DOT com Date: Mon, 23 Jan 2006 20:30:45 +0000 (GMT) Subject: Re: Serial port hangs unless I run Hyperterminal? Message-ID: <4dede53945AndyBurgess@argonet.co.uk> In-Reply-To: <43D4E0CB.3080106@byu.net> References: <4dedbe8ed5AndyBurgess AT argonet DOT co DOT uk> <43D4E0CB DOT 3080106 AT byu DOT net> User-Agent: Pluto/3.03h (RISC-OS/4.02) POPstar/2.06-ds.3 Content-Type: text/plain X-orpheus-MailScanner: Found to be clean X-orpheus-MailScanner-SpamCheck: not spam, SpamAssassin (score=0.09, required 5, autolearn=disabled, AWL 0.09) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Eric, Thanx for your quick reply! > Code snippets? OK - open port function following function called with serial = open_port("COM1"); ----------------------------- int open_port(char *port) { int fd = 0; fd = open(port, O_RDWR | O_NOCTTY ); return (fd); } ----------------------------- // writing to port (I don't use tcgetattr or tcsetattr ATM). int res; res = write(fd, cmd, strlen(cmd)); if (res < 1) { printf("write failed\n"); return (-1); } ----------------------------- //read feedback char buf[350]; res = read(fd, buf, 1254); ----------------------------- > Are you using the correct port? I'm not 100% sure - perhaps you can tell me. I'm using COM1 as encoded in program snippet above. From what you say below - sounds like wrong one! > More details would have > been nice. Cygwin serial port setting commands emulate Linux, so you > should use on "/dev/ttyS0" and not on "COM1". Right - so from the above I should do: serial = open_port("/dev/ttyS0"); instead? > Also, from the command line, you can use "stty -f /dev/ttyS0" to read and > set the settings of your port, rather than relying on hyperterm. Right did that - though it seemed to be capital F parameter on my Cygwin. Hope it's the same setting! The reply was (after Hyperterminal had been run, and program was running OK): speed 0 baud; line = 0; intr = ; quit = ; erase = ; kill = ; eof = ; swtch = ; susp = ; rprnt = ; werase = ; lnext = ; flush = ; min = 0; time = 0; -cread -brkint -icrnl -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke I presume the "-" prefixed settings mean "off", and the hashes - continuations? Is there anything there a cause for concern - they all look pretty uninitialised to me! Nice to see all those settings available to be viewed outside of tcgetattr - I'd wondered how I could do that. If I used "/dev/ttyS0" instead of COM1, would the tcget/setattr's work? Does it mean that currently I'm somehow getting some settings passed from the Win32 environment for my current COM1 settings? If so, is there a way I can interrogate these to set up for use with correct ttyS0? Apologies for not understanding /dev/ttyS0. I've done fair amounts of stuff on DOS, and a fair bit of unix (scripts, but rusty), but until recently had never programmed serial ports on any POSIX or DOS system, or even used any Unix "device" myself! I presume COM2, COM3 etc would be mapped to ttyS1, ttyS2 etc? > - -- > Life is short - so eat dessert first! Sounds like a 'top' idea! Cheers for your help! Andy -- __ __ __ __ __ ___ _____________________________________________ |__||__)/ __/ \|\ ||_ | / | || \\__/\__/| \||__ | /...Internet access for all Acorn RISC machines ___________________________/ andyburgess AT argonet DOT co DOT uk -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/