Unoffical empeg BBS

Quick Links: Empeg FAQ | RioCar.Org | Hijack | BigDisk Builder | jEmplode | emphatic
Repairs: Repairs

Topic Options
#29321 - 10/04/2001 04:20 Sending serial data at startup
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Being brand spanking new to Linux, maybe one of you old hands can help.

I have a REDRat2 serial to IR learning remote type thing which plugs into a standard 9-way port (normally on m PC). I can use it on the PC to learn commands from consumer IR remotes, save as text and then send them back to the unit to make it send the correct IR out to control anything.

It seems like I may be able to use this on the empeg serial port when docked at home.

What I want to do is send a string of data to the serial port when the empeg is plugged in. I can then make this string set up my HT system to be ready for empeg input without touching a thing.

It seems from my VERY limited knowledge of Linux that I can put a line in the init script to send the codes from a file to the serial port. Is this right ? In DOS I would use:

mode com1:9600,n,8,1,p
copy /b IRfile.txt com1:

How do I do this on the empeg? Can I use cat or cp? How do I set the port's settings (baud rate, parity etc.)?

All help appreciated as always.

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29322 - 10/04/2001 04:44 Re: Sending serial data at startup [Re: Dava]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Having thought about it a little more, It would be a major benifit if I could send this data or just some message to a specific port on a specific IP address using UDP. This way I could leave my RedRat2 connected to my main PC and write a VB app to listen at this port and do all the dirty stuff when it receives something?

Having a good idea of my Linux ineptitude by now, is this going to be easy too?

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29323 - 16/04/2001 04:22 Re: Sending serial data at startup [Re: Dava]
jane
enthusiast

Registered: 10/10/2000
Posts: 350
Loc: Copenhagen SW, Denmark
You can do this quite asilly if your VB app can listen to a TCP port instead. Then the Server-script could just do a

echo Empeg on| telnet 10.0.0.1 5555

This will send the message to the server 10.0.0.1 on TCP port 5555

Marius (Escort Cab + Mark II)


Top
#29324 - 17/04/2001 09:09 Re: Sending serial data at startup [Re: jane]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Thanks Jane,

Sounds perfect - but I have not looked on the empeg to make sure I have telnet yet!

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29325 - 17/04/2001 11:34 Re: Sending serial data at startup [Re: jane]
fvgestel
old hand

Registered: 12/08/2000
Posts: 702
Loc: Netherlands
Unfortunately this doesn't work. telnet connects the user's terminal to the remote machine. It will not read from an echo command, only from the tty-device. There is some program called netcat which should do the job. Let me see where it is...

Frank van Gestel
_________________________
Frank van Gestel

Top
#29326 - 17/04/2001 12:56 Re: Sending serial data at startup [Re: fvgestel]
fvgestel
old hand

Registered: 12/08/2000
Posts: 702
Loc: Netherlands
here it is... compiled binary and original tgz-file. the tgz-file contains all documentation and example scripts and can be opened using winzip
upload to the empeg using hyperterm. use :

chmod +x nc

to make it executable.
Good Luck

Frank van Gestel


Attachments
28759-netcat_empeg.zip (104 downloads)

_________________________
Frank van Gestel

Top
#29327 - 18/04/2001 02:16 Re: Sending serial data at startup [Re: fvgestel]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Hmm, Frank.

I will start to dream about you soon.

Thanks a million.

PS. I have completed the VB part and it works fine from my laptop, so this is the missing link. I will let you know how netcat works. I couldn't find telnet on the empeg anyway.

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29328 - 18/04/2001 02:27 Re: Sending serial data at startup [Re: fvgestel]
jane
enthusiast

Registered: 10/10/2000
Posts: 350
Loc: Copenhagen SW, Denmark
It works for me.

Marius


Top
#29329 - 18/04/2001 04:17 Re: Sending serial data at startup [Re: fvgestel]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
OK, so this works perfectly but only after the player has been run.
It seems to be the player app which does the DHCP stuff and I dont seem to have an IP before running it.

Could I either; run it in the background so that the player has had time to negotiate an IP, or get an IP before the player runs?

If so how?

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29330 - 18/04/2001 05:08 Re: Sending serial data at startup [Re: Dava]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
It seems to be the player app which does the DHCP stuff

This is correct. The player application does the DHCP stuff.

You might try recompiling the kernel with "Kernel Level Autoconfiguration" turned on. IIRC, this allows the kernel to do the DHCP stuff.

You never know, it might even work.


Roger - not necessarily speaking for empeg
_________________________
-- roger

Top
#29331 - 18/04/2001 06:01 Re: Sending serial data at startup [Re: Roger]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Thanks but far too scarey for me.

How about a delay?

It seems that if I put an & at the end of the line in init which calls my script it runs as a separate process (this is what I was told).

So if my thinking is correct, I can put a delay of some sort in the start of my script (call it then the original init) so that the netcat bit only happens after the player has started.

Is this right?

How do I delay for 5 secs in a script?

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29332 - 18/04/2001 06:44 Re: Sending serial data at startup [Re: Dava]
mtempsch
pooh-bah

Registered: 02/06/2000
Posts: 1996
Loc: Gothenburg, Sweden
How do I delay for 5 secs in a script?

stuff before pause
sleep 5
stuff after pause

should do it...

/Michael

_________________________
/Michael

Top
#29333 - 18/04/2001 07:00 Re: Sending serial data at startup [Re: mtempsch]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Thanks, but I don't have sleep.

Does anyone have the executable?

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29334 - 18/04/2001 08:00 Re: Sending serial data at startup [Re: mtempsch]
fvgestel
old hand

Registered: 12/08/2000
Posts: 702
Loc: Netherlands
unfortunately sleep isn't installed on the empeg. I was thinking of a loop which runs till the command succeeds :


send_msg() {
while [ "$END" != "0" ]
do
echo empeg on | ./nc -w 5 192.168.1.1 5555
END=$?
done
}

send_msg&
init.empeg


or


export TARGET_IP=129.168.1.1
export TARGET_PORT=55555
(ping -w 20 $TARGET_IP >/dev/null 2>&1; echo empeg on | ./nc -w 5 $TARGET_IP $TARGET_PORT)&
init.empeg


this waits for 20 seconds for ping before starting nc


Frank van Gestel
_________________________
Frank van Gestel

Top
#29335 - 18/04/2001 08:28 Re: Sending serial data at startup [Re: fvgestel]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Thanks, but I have no ping either!!

I will try method 1.


MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29336 - 18/04/2001 09:04 Re: Sending serial data at startup [Re: fvgestel]
Dava
member

Registered: 06/12/2000
Posts: 192
Loc: Bucks UK
Welll done Frank,

Method 1 works fine. The player starts then the empeg sends that data as requested and then I presume the process quits.

The only problem is that if no network is connected it does this:

empeg-car 1.02.
3ae0421b DHCP Our address is 255.255.255.255
3ae0421b DHCP Broadcast address is 255.255.255.255
3ae0421b DHCP Current IP address is 255.255.255.255
3ae0421b DHCP Sending DHCP discover
3ae0421c DHCP Sending DHCP discover
3ae0421e DHCP Sending DHCP discover
neighbour table overflow
neighbour table overflow
3ae04222 DHCP Sending DHCP discover
neighbour table overflow
3ae04229 DHCP Sending DHCP discover
neighbour table overflow
neighbour table overflow
neighbour table overflow
neighbour table overflow
neighbour table overflow
neighbour table overflow
3ae04236 DHCP Sending DHCP discover
neighbour table neighbour table overflow
neighbour table overflow
neighbour table overflow
neighbour table overflow


Now is that going to cause a problem eventually?

I will suck it and see in the car.

Again thanks for your patience.

MK2 Red S/n 949
_________________________
MK2 smoked 32Gb S/n 090000949 MK2a Blue 20GB racked and out of sync

Top
#29337 - 18/04/2001 09:21 Re: Sending serial data at startup [Re: Dava]
fvgestel
old hand

Registered: 12/08/2000
Posts: 702
Loc: Netherlands
the neighbour table overflow is caused by the loopback interface not being enabled. I think you will need the command ifconfig to set it :
ifconfig lo 127.0.0.1
maybe it can be done by catting an entry in /proc somewhere?

I must warn you; if it outputs too many stuff to the serial port when there is no receiver on the other end, it can slow down the IR-response

You can also check if you are in the car with a line in your shell-script. Can't remeber right know. Search the BBS for custom init-scripts and you will find various answers...

Frank van Gestel
_________________________
Frank van Gestel

Top