Author Topic: HELP PLEASE!  (Read 623 times)

0 Members and 1 Guest are viewing this topic.

Offline Marvin_G

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
  • I've just joined!
    • View Profile
    • Awards
HELP PLEASE!
« on: February 06, 2013, 08:58:36 am »
guys,i have a problem sending command through terminal to the serial port. i've already set the baudrate, start bit,data bits, stop bit, and parity bit using stty command. now i just have to send few 8bits data (0xF5,0x01,0x00,0x01,0x03,0x01,0x03,0xF5) to the the external device but it just wont work. below is my serial port setting

Quote
root@ubuntu:~# stty -a </dev/ttyUSB0
speed 19200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^A; stop = ^A; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
-iuclc -ixany -imaxbel -iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

and this is how i sent my data in terminal which result in nothing. please help me guys,i'm so desperate right now! T.T. and 1 more thing is i need to read replies data from the device. any idea?

Quote
echo -e '\F5\01\00\01\03\00\03\F5\' >/dev/ttyUSB0

p/s: i've used cutecom software and it works perfectly but i dont want to use any software. If possible i want to use only the terminal alone. please please please help me.

Offline Mad Penguin

  • #Mad_Penguin_UK
  • Administrator
  • Hero Member
  • *****
  • Posts: 1318
  • Karma: 10016
  • Gender: Male
    • View Profile
    • Linux in the UK
    • Awards
Re: HELP PLEASE!
« Reply #1 on: February 06, 2013, 11:05:22 am »
Erm, how about a little 'c' code ?? Something like;
[disclaimer :: this is *very* rough and does no error checking, but it works]

Code: [Select]
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>

extern int errno;

void main()
{
char buffer[128];
int out = open("/dev/tty2",O_WRONLY);
int inp = open("/dev/tty2",O_RDONLY);
sprintf(buffer,"Enter your name: ");
write(out,buffer,strlen(buffer));
read(inp,buffer,sizeof(buffer));
strtok(buffer,"\n");
printf("You typed [%s]\n",buffer);
}
Sample run;
Code: [Select]
initctl stop tty2
# ./term
Quote
<Ctrl>+<Alt>+F2
(type "MadPenguin")
<Alt>+<F7>
Code: [Select]
You typed [MadPenguin]
Obviously you'd swap "tty2" with your device of choice ... (USB0?)
[you can call an stty routine first in the code if necessary]

Compile the code with;

Code: [Select]
gcc term.c -o term 
(assuming you name the above file "term.c")
https://twitter.com/#!/Mad_Penguin_UK

Offline Marvin_G

  • Jr. Member
  • **
  • Posts: 8
  • Karma: 0
  • I've just joined!
    • View Profile
    • Awards
Re: HELP PLEASE!
« Reply #2 on: February 07, 2013, 01:07:16 am »
i'm thinking of using only the old-style terminal if possible. is there any other way? to configure the baudrate,databits,parity bits, and start/stop bit just by using old-style terminal?

Offline Mad Penguin

  • #Mad_Penguin_UK
  • Administrator
  • Hero Member
  • *****
  • Posts: 1318
  • Karma: 10016
  • Gender: Male
    • View Profile
    • Linux in the UK
    • Awards
Re: HELP PLEASE!
« Reply #3 on: February 07, 2013, 09:59:20 am »
Erm, as per the other thread ..

The thing that presents the login prompt is "getty".
To configure the login prompt for a serial console, you need an entry in /etc/init to match the device in question.
(/etc/init/usb0 ??)

You set the serial port options as part for the "exec" "getty" line in this file (!)
https://twitter.com/#!/Mad_Penguin_UK

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal