Unoffical empeg BBS

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

Topic Options
#287196 - 27/09/2006 01:09 program reads from serial port fine out of car, not in car
jag
new poster

Registered: 14/02/2002
Posts: 21
Does anyone have any hints as to why my program would read data from the serial port with no problem when out of the car but has trouble when in the car?
I have assigned the port to user applications (through hijack).
When I was writing the program in my house with the player in forced DC mode, it worked great. Now when I try to use it in the car it won't work.

I have plugged my laptop into the player (in the car) and seen the boot up messages and been able to send commands to the player program (after changing the serial port mode through hijack).

I am using a null modem adapter with the in car serial port (I tried it without as well) since the device I'm trying to access is meant to be plugged into a PC serial port.
I can see data from the device fine with my laptop.

I just wanted to see if I was missing something obvious before I try to debug more (I guess I'll try to get an ethernet connection to the player while in the sled...)
Any advice would be appreciated.
In case it helps, the device I'm trying to listen to is an Innovate Motorsports LC-1 wideband oxygen sensor.
Thanks!

-Jeremy

Top
#287197 - 27/09/2006 02:59 Re: program reads from serial port fine out of car, not in car [Re: jag]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
The speed is different in-car and out-of-car. You can force it with a config option. Take a look in the FAQ.
_________________________
Bitt Faulk

Top
#287198 - 27/09/2006 06:51 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
Roger
carpal tunnel

Registered: 18/01/2000
Posts: 5683
Loc: London, UK
Also, IIRC, in the car, the serial port doesn't need the null-modem adapter.
_________________________
-- roger

Top
#287199 - 27/09/2006 11:37 Re: program reads from serial port fine out of car, not in car [Re: Roger]
jag
new poster

Registered: 14/02/2002
Posts: 21
I tried with & without a null modem adapter to be sure. I assume the speed would be behaving the same in the car and in forced DC mode.
My program changes the baud rate by itself though so it shouldn't matter if the speed is already set to something different.

I'm going to try to do some more debugging today...
It's frustrating though. I thought I had the program working great until I got out to the car...

Top
#287200 - 27/09/2006 13:15 Re: program reads from serial port fine out of car, not in car [Re: Roger]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Actually, isn't that just because TX and RX were flipped? ISTR that the car plug is actually wired wrong. It's probably in the FAQ somewhere, but I can't find it ATM.
_________________________
Bitt Faulk

Top
#287201 - 27/09/2006 14:05 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
sein
old hand

Registered: 07/01/2005
Posts: 893
Loc: Sector ZZ9pZa
This FAQ entry says the following:

Quote:
Also, according to Hugo, Mark 2 units with serial numbers below 1050 are be missing a ground wire on the in-car serial connector. To get them to work, you need to connect a ground wire between your laptop's serial cable shroud and a ground point on the vehicle. Another thing to remember is that the serial port on the docking sled is already "crossed over" with the RX and TX pins swapped. So you need to use a straight-through serial cable instead of the supplied null-modem cable if you're connecting your PC to the docking sled's serial connector.

Do you have an early Mk2?
_________________________
Hussein

Top
#287202 - 27/09/2006 14:48 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Quote:
Actually, isn't that just because TX and RX were flipped? ISTR that the car plug is actually wired wrong. It's probably in the FAQ somewhere, but I can't find it ATM.


Yes. This is most likely the reason. The appropriate FAQ entry is this one:

I can't perform an upgrade, install a logo, or install a kernel when the player is in the docking sled..

Edit: Wait, he said he tried it both with and without the null modem adapter.

Maybe it's one of the other things listed in that FAQ entry. But the important thing to remember is this: When you plug straight into the back of the empeg, it must be a null-modem cable. When you plug into the docking sled, it must NOT be a null modem cable.

Another possibility is that Hijack is doing something special in DC mode that it's not doing in AC mode. But he said he tried "force DC"... Does it work indoors when you try Force DC?

Top
#287203 - 27/09/2006 14:54 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
jag
new poster

Registered: 14/02/2002
Posts: 21
My unit is a riocar, not an empeg so I assume it has the grounds. Regardless, it worked when I connected my laptop to it through the sled serial port so I assume it must have the grounds. So, if I can connect it to my laptop without a null modem adapter then to connect it to the wideband (which also connects to a computer without a null modem adapter) I must have to use a null modem adapter to swap the RX and TX so they can talk. But, it doesn't seem to work. I'm going to go out in a bit and try connecting it to the wideband in the car while it is on AC power to see if the problem is something to do with the wideband when it is installed in the car.
The strange thing is that I can talk to both of them with my laptop so it seems to me that they should be able to talk to each other unless there is something funky going on with a ground loop or the voltages for the wideband being out of spec...
I'll let you know what I find (if anything).

Top
#287204 - 27/09/2006 15:14 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
jag
new poster

Registered: 14/02/2002
Posts: 21
I tried force DC indoors, that's when it works. I haven't tried it outdoors, it didn't seem to me it would make a difference. I'm going to go out in a little while and try "force dc" with it in the sled and with it out of the sled on AC power.

Top
#287205 - 27/09/2006 15:17 Re: program reads from serial port fine out of car, not in car [Re: jag]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Wait, I see what you're talking about...

You're not having problems getting your computer to see the empeg's output...

Your problem is getting your little program that you've written that RUNS ON THE EMPEG to read the output FROM THE OXYGEN SENSOR device when both are installed into the car.

So the cables you're using... Are they custom cables you've made, or are they off the shelf things? I think the off the shelf cables might link certain pins on that device to lines you don't want them to. Pin 1 goes to phone mute and Pin 4 goes to amp remote (on the sled). Maybe those things are confusing the oxygen sensor device. Since pin 1 is supposed to be Carrier Detect and pin 4 is supposed to be Data Terminal Ready, I could see how this might happen.
_________________________
Tony Fabris

Top
#287206 - 27/09/2006 16:16 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
I thought I remembered that the issue with the sled's serial connector was that the TX and RX were swapped without the RTS and CTS and other lines being appropriately swapped. A null-modem connector won't fix that. It could still work or not depending on what settings are set on the serial port when it's opened from the OS.
_________________________
Bitt Faulk

Top
#287207 - 27/09/2006 17:31 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
jag
new poster

Registered: 14/02/2002
Posts: 21
Hi all,

The RTS and CTS shouldn't matter as only the RX, TX and ground are connected to the wideband serial connector.
I just got back from testing it with the empeg connected to an AC power supply (out of the sled) using the connector on the back of the unit. I totally expected it to work but it didn't.
So, the problem seems to have to do with the installation of the wideband in the car. When I tested it out of the car I was using a small battery to power the wideband and a wall wart to power the empeg. Now the wideband is using the car battery. I'm not sure what the difference is.
The wideband is communicating with my laptop fine, just not with the empeg either in the sled or out. I am going to connect an ethernet cable to the empeg and put some debugging code in the program and see if it is seeing any input over the serial port.

I guess I could also just try cat /dev/ttyS1 to see if anything is coming in over the port...


Edited by jag (28/09/2006 00:11)

Top
#287208 - 27/09/2006 19:13 Re: program reads from serial port fine out of car, not in car [Re: jag]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Quote:
The RTS and CTS shouldn't matter as on the RX, TX and ground are connected to the wideband serial connector.

That's not necessarily true. A null-modem, in addition to swapping RX and TX, loops back the RTS and CTS lines so that they're always on. If those pins aren't in the right place, you might never be getting the lines set properly on the empeg side, which means that the program might never be able to write or read from the port.
_________________________
Bitt Faulk

Top
#287209 - 27/09/2006 20:30 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Quote:
as on the RX, TX and ground are connected to the wideband serial connector.

I think that was a typo, and he meant to say "as ONLY the RX, TX and ground are connected". So it seems he had already wired it that way, so those other pins are irrelevant in his case.
_________________________
Tony Fabris

Top
#287210 - 27/09/2006 20:54 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
No, they're not irrelevant. As I said, null modem connectors loop some of the other connectors back to the empeg side. If it's looping back the wrong connections, things can fail.
_________________________
Bitt Faulk

Top
#287211 - 27/09/2006 21:56 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Quote:
As I said, null modem connectors loop some of the other connectors back to the empeg side.


I'm confused. He said he's using the sled in the car. When I look at this wiring diagram, it shows that the only things connected to pins 1 and 4 at the empeg side are the phone mute line and the ignition sense.

I could understand how having those two things go high or low could theoretically mess up an external device. But I don't see how a null-modem cable looping anything to either of those pins would mess up serial communication on the empeg?
_________________________
Tony Fabris

Top
#287212 - 27/09/2006 22:58 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Look at a wiring diagram for a null-modem connector. The TX and RX lines are not looped back. They're swapped. Lines that are looped back and shorted include CTS and RTS. If the empeg connector isn't wired right (which, again, I seem to recall, but can't find documentation for at the moment), it might be looping back ground to CTS, which wouldn't raise it, and the OS would refuse to send data out the TX line, possibly depending on the options with which the port was opened.

Honestly, I hadn't done a lot of research into this to see exactly what happens in this configuration. I didn't think it was a difficult concept, and just required someone to chime in with better search-fu than mine at the moment to confirm that my memory of the incorrect wiring was correct and to see if it had any effect on the RTS or CTS (or any other signals, like DSR and DTR, possibly) lines.
_________________________
Bitt Faulk

Top
#287213 - 28/09/2006 00:00 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Okay, I think I see what you're saying. But I still don't think it applies unless I misinterpreted his typo.

I'm saying, the only way your description would be an issue is if a stray pin (any pin other than TX RX and GND) on the null modem cable made a connection from his external device to the empeg, or loopbacked to his device. But that can't be, because he said that at his device's end (assuming I read his typo correctly), it only has TX RX and GND connected.

And we know the empeg's sled connector only has TX RX and GND connected.

So even if the null modem cable put loopbacks on every single pin (other than TX RX and GND), it wouldn't affect either device. In this configuration, they're just wires dangling in midair not touching anything other than themselves.

The only way this would be an issue is if somehow the empeg sled was so badly miswired that another wire was connecting TX or RX to something they shouldn't be. I've never heard of that happening on an empeg sled. Or the loopback cable is so badly miswired that it's connecting other stray pins to the TX and RX.

Other possibilities are: his device really does use those other pins, I've misinterpreted his typo, or things are just completely miswired at his device's end.
_________________________
Tony Fabris

Top
#287214 - 28/09/2006 00:15 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
jag
new poster

Registered: 14/02/2002
Posts: 21
Wow, you guys have been busy discussing this in my absence

Tony is right about my typo, I meant "only".

So, the handshaking lines shouldn't matter at all since I have handshaking turned off in my program, my program also sets the baud rate first thing so that shouldn't be a problem either.
Also, I have determined that the problem isn't with the sled since the program is no longer working from the port on the back of the empeg as well.
I'm guessing that something is going on with the wideband when it is installed in the car that wasn't happening when it was on my kitchen counter (where I wrote the software).
The thing that is strange to me is that my laptop can talk to it fine. Is the empeg known for having a finicky serial port?
I didn't get around to hooking an ethernet line up to the empeg today to see if I could do some debugging. I'll hopefully do that in the morning.
It's a strange thing. I had it working great in my kitchen and then installed the wideband in the car and went to test it. I then realized that the sled serial port was different and assumed that must be the problem. It seems that my assumption was wrong and there is something else strange going on here...
Thanks for all of the analysis though!
I'll keep you posted if I learn anything.

-Jeremy


Edited by jag (28/09/2006 00:17)

Top
#287215 - 28/09/2006 00:58 Re: program reads from serial port fine out of car, not in car [Re: jag]
jag
new poster

Registered: 14/02/2002
Posts: 21
Solved!

I'm sorry to say that after all of this discussion, it was just a stupid programming error. I leapt to the wrong conclusion to quickly.

At some point I had made a change in the program to make it set the output baud rate to zero. My hope was that even if it didn't actually turn off the output, it would make it so incomprehensible that any status messages that the empeg was giving on the serial port wouldn't contain any real letters and be interpreted as commands to the wideband.
It worked fine on the bench but for some reason stopped working when I moved it to the car (perhaps because that was the first reboot since I had made the change).
I don't even know what the behavior is supposed to be if you try to set the output baud to 0, I was just trying it out.
Anyway, I set the output baud rate to the same as the input baud rate and it seems to be behaving fine.
Now I just have to pull the sensor out of the exhaust tomorrow and calibrate it...
Thanks for the help, I'm sorry it was a stupid problem not at all related to what I thought it was...
Live and learn.

-Jeremy

Top
#287216 - 28/09/2006 01:11 Re: program reads from serial port fine out of car, not in car [Re: jag]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Glad it's all sorted.

I just think it's cool people are continuing to do projects like this.
_________________________
Tony Fabris

Top
#287217 - 28/09/2006 01:45 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Clearly this was not his problem, but you still don't get it. I'm going to try to explain this once again, hope that it makes more sense to you this time, and drop it.

When you have a serial connection, a normal one without a null-modem connection, there is a signal called CTS, or Clear To Send. When this pin is high, it means that the device is ready to receive data. If hardware handshaking is turned on on the terminal, it will wait until CTS is high before it sends data.

When you have two terminals connected together via null-modem cable, things in regards to CTS go haywire. Since the RS232 protocol was written such that the terminal and the device have different functions, you can't just swap CTS with RTS (Ready To Send) and have everything work correctly. In order to get around this problem, null-modem connectors are designed so that CTS is looped back to RTS and is crossed with (I believe) remote DCD (D? Carrier Detect) the notion being that DCD should always be high and will pull up both CTS and RTS, jury rigging the hardware handshake. Similar games are played with DSR and DTR (Data Set/Terminal Ready).

If the empeg's serial port is wired incorrectly, The loopback and short might fail to pull CTS high on the empeg, regardless of what was on the opposite end, thus preventing the hardware handshake from being fooled. This is avoidable if you open the port without hardware handshake on, but it could conceivably cause other problems, depending on a variety of variables.

Again, this obviously wasn't the problem here, but it easily could have been. I'd still like some corroboration as to how the sled's serial port is wired wrong.
_________________________
Bitt Faulk

Top
#287218 - 28/09/2006 03:50 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Quote:
If the empeg's serial port is wired incorrectly, The loopback and short might fail to pull CTS high on the empeg

And I'm saying... The serial port on the empeg's sled doesn't even have a CTS pin, and there isn't even a way to connect one, no matter how badly the thing is miswired.

The serial port on the empeg's sled connects to the interior of the empeg via the floaty-black gold-plated docking-port connector thingy, and that's got only two pins for the serial connection (if you don't count ground). Those pins are dedicated to TX and RX, and nothing else. There's no way to get a CTS signal (or any other signal other than TX or RX) from outside the sled to inside the player, no matter how hard you try. The worst you could do is screw up the TX and RX signals.

And, as he just confirmed, the same thing existed at the other end of his connection.

So how, in that situation, do you propose that doing things with the CTS wire, or any other wire besides RX and TX, could affect the player or his device?

Quote:
I'd still like some corroboration as to how the sled's serial port is wired wrong.

It connects the Amp Remote wire and the Phone Mute wire to pins 1 and 4 on the sled's serial port. I don't know why they designed it this way. But the worst THAT could do is confuse the device connected to the other end of the cable, not confuse the empeg itself.
_________________________
Tony Fabris

Top
#287219 - 28/09/2006 05:59 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
mlord
carpal tunnel

Registered: 29/08/2000
Posts: 14496
Loc: Canada
All of what Bitt is saying *might* be applicable to the gadget that is being connected to the empeg, at the other end of that same null modem cable. But the empeg software itself doesn't care about RTS/CTS DTR/DSR CD/RD etc.. for serial port communications. So those are all "don't care" lines from that point of view, and most of them are not connected internally regardless.

However, *some* of those extraneous signals *are* actually connected to stuff inside the empeg, but they are used for things like "carphone mute", "headlight sense", etc..
So having them wired up could be bad regardless.

Cheers

Top
#287220 - 28/09/2006 06:49 Re: program reads from serial port fine out of car, not in car [Re: mlord]
Shonky
pooh-bah

Registered: 12/01/2002
Posts: 2009
Loc: Brisbane, Australia
For the record, my take on the empeg sled serial port mix up is here:
http://empegbbs.com/ubbthreads/showthreaded.php/Number/116302#116302
_________________________
Christian
#40104192 120Gb (no longer in my E36 M3, won't fit the E46 M3)

Top
#287221 - 28/09/2006 09:45 Re: program reads from serial port fine out of car, not in car [Re: tfabris]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Quote:
The serial port on the empeg's sled connects to the interior of the empeg via the floaty-black gold-plated docking-port connector thingy, and that's got only two pins for the serial connection (if you don't count ground). Those pins are dedicated to TX and RX, and nothing else. There's no way to get a CTS signal (or any other signal other than TX or RX) from outside the sled to inside the player, no matter how hard you try. The worst you could do is screw up the TX and RX signals.

That wiring diagram you posted showed connections on pins 1, 2, 3, 4, 5, and 8. I know that they're wired funny, but on a normal DB9 RS232 connector, those would be RX, TX, DCD, DTR, G, and DSR. There's no legend telling me what they're actually wired to. If you could confirm that TX and RX are the only things wired up that have to do with serial connections, then that would tend to confirm my remembrance that the serial port is hooked up wrong, but disprove my theory. So far, you've yet to do that. (And I tried to find where that diagram was in the FAQ, but failed.)
_________________________
Bitt Faulk

Top
#287222 - 28/09/2006 09:47 Re: program reads from serial port fine out of car, not in car [Re: Shonky]
wfaulk
carpal tunnel

Registered: 25/12/2000
Posts: 16706
Loc: Raleigh, NC US
Thank you.
_________________________
Bitt Faulk

Top
#287223 - 28/09/2006 17:03 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Quote:
There's no legend telling me what they're actually wired to.


Sorry, woops, that was in the other diagram. Both diagrams are linked from here

I'd actually missed pin 8 during this discussion because it was labeled in such a light gray color on that chart.

Anyway, the only things that the empeg uses for serial communication are pins 2, 3, and 5 (rx tx gnd), and those other pins (1 4 8), although they're used on a REAL serial port, aren't connected to any serial port circuits inside the empeg. Those are connected to amp remote, phone mute, and headlight sense.
_________________________
Tony Fabris

Top
#287224 - 28/09/2006 17:09 Re: program reads from serial port fine out of car, not in car [Re: wfaulk]
tfabris
carpal tunnel

Registered: 20/12/1999
Posts: 31600
Loc: Seattle, WA
Quote:
Thank you.

Aha. Re-reading that old thread about the serial port wiring, he was talking about the same thing I was saying all along: At ***HIS END***, the computer was getting confused by by the handshaking pins being wired to amp/mute/headlight.

I've been saying this all along: Sure that can happen, but only if the device at the other end of the cable is a) connected to those pins, and b) programmed to respond to signals on those pins. That didn't count in Jag's situation because he said only TX RX and GND were connected at his end.
_________________________
Tony Fabris

Top