PcmHammer on Linux

User avatar
Gareth
Posts: 2681
Joined: Fri Mar 14, 2014 10:37 am
Location: Bacchus Marsh, Vic

Re: PcmHammer on Linux

Post by Gareth »

The next challenge I think is we now have a number of front ends, too many perhaps, and especially with AI it is possible to crank them out. But for users they will have too many options. So the next main thing is code maintainers who are going to hang around and be able to support this stuff for a more extended period. I think some experimental code up for testing is a good thing, but the challenge is going to be how to decide what goes mainstream.
Spot on Ant, there is a flood of development happening across lots of areas and the water is getting murkier not clearer!!

There needs to be a better way
According to chemistry, alcohol is a solution...
User avatar
antus
Site Admin
Posts: 10111
Joined: Sat Feb 28, 2009 10:34 am
cars: TX Gemini 2L Twincam 8psi
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Subaru WRX 2007

Re: PcmHammer on Linux

Post by antus »

Gene Thompson wrote: Wed Nov 11, 2026 12:58 am SInce atshaw1994 is already working on Avalonia, sounds as if UNO may be reinventing the wheel?
Yeah. UNO was NSFW's first attempt at a gui version styled to work on a tablet. It can work, but as above with the problems. MAUI is a more modern equivalent but has some issues. Avalonia is not from microsoft but it is free and cross platform and well established. It gets it right and it's so popular I don't think it is going away any time soon.

In my head I'd like to see it go to Avalonia and drop UNO. I had a good chat with atshaw1994 and understand the benefits of the MVVP design choices and the Avalonia toolkit. I'm pretty sold. It just needs to happen. Once the beta has landed others can take a look and contribute there. If you're interested to try and checkout atshaws branch and take a look. If using claude get it to document the changes so that it can re-create it on a future version when its in. I spoke to attshaw94 this morning and pointed him to this thread. He's busy at the moment but hopefully he pops his head up and we can consider when we bring the work in from his branch.
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
Gene Thompson
Posts: 20
Joined: Mon Mar 14, 2022 10:06 pm
cars: 1965 Impala SS
1965 Chevelle SS
1970 Chevelle SS

Re: PcmHammer on Linux

Post by Gene Thompson »

I downloaded and had a look and attempted a read but it failed. I had the same issue with UNO until I made a couple changes. Not sure if atshaw1994 has already worked this out or not.
What is your thought on the logger? Incorporate it in like the UNO frontend was doing or keep a stand alone version?
You do not have the required permissions to view the files attached to this post.
User avatar
antus
Site Admin
Posts: 10111
Joined: Sat Feb 28, 2009 10:34 am
cars: TX Gemini 2L Twincam 8psi
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Subaru WRX 2007

Re: PcmHammer on Linux

Post by antus »

I think keep it seperate, but try to adhear to MVVM type design and put as much of the shared logic in pcmlibrary as possible with the seperate front end only doing dumb front end stuff. That way the heavy lifting is backend and its easy to change what we do when we want, and also easy to keep the logic shared between different front ends.

atshaw84 told me its not ready yet, but I can see its still being worked on. if your are ready to go you could fork it again from his and have a bit of a play, and post here if you hit a milestone and keep your tree open too and then he could sync up, or we could agree which branch to merge back in to pcm hammer.

He showed me he was having issues with the block checksum failing to match on receive, check your debug log, it could be the same thing. Then check if the whole packet is there, and check the sum manually versus what the app calculates and see why its not matching. The kernel should be doing the right thing and the sum should be right.
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
User avatar
atshaw1994
Posts: 5
Joined: Tue Jun 30, 2026 5:53 am
cars: 2023 Kia Soul LX
1997 Chevrolet Tahoe 5.7/4L60e

Re: PcmHammer on Linux

Post by atshaw1994 »

atshaw1994 has joined the chat!

I'm using Claude Sonnet 5.5 in Visual Studio and simply feeding it the result and debug logs and letting it do its thing. I'm a UI guy and don't have a very deep understanding of PCM operations.

Claude made the following edits so far:
OBDXProDevice.cs at line 381:

Code: Select all

byte[] receive = new byte[Length + 3 + offset];
receive[0] = rx[0];//Command
receive[1] = rx[1];//length
if (rx[0] == 0x09) receive[2] = rx[2];//length long frame

// Read the rest of the frame incrementally. The OS receive queue can be smaller than
// the frame (Linux tty buffers are ~4 KiB), so we can't wait for the whole frame to be queued.
int needed = Length + 1;
int received = 0;
while (received < needed)
{
    Chk = await WaitForSerial(1);
    if (Chk == false)
    {
        this.Logger.AddDebugMessage("Timeout.. no data present F");
        return Response.Create(ResponseStatus.Timeout, (Message)null!);
    }

    int available = await this.Port.GetReceiveQueueSize();
    int toRead = Math.Min(Math.Max(available, 1), needed - received);
    int bytes = await this.Port.Receive(receive, 2 + offset + received, toRead);
    if (bytes <= 0)
    {
        this.Logger.AddDebugMessage("Failed reading " + Length + " byte packet");
        return Response.Create(ResponseStatus.Error, (Message)null!);
    }

    received += bytes;
}
KernelVerifier.cs at line 135:

Code: Select all

// The PCM can take several seconds to compute a large CRC. Wait for the reply
// instead of re-sending the query, which would desync replies and flood the PCM.
Message response = null;
for (int wait = 0; wait < 10 && response == null; wait++)
{
    if (cancellationToken.IsCancellationRequested)
    {
        return CrcVerificationResult.Cancelled;
    }

    response = await this.vehicle.ReceiveMessage();
    if (response == null)
    {
        await this.vehicle.SendToolPresentNotification();
    }
}
Claude thinks:
Cause:
The P11 kernel needs more than 1 second to compute the CRC of a 64 KB range. The old code treated that 1-second silence as a timeout and re-sent the CRC query. The repeated queries flooded the PCM and desynced the replies. After 6 timeouts it gave up on each range, which is why 0x40000 down to 0x00000 failed while the earlier ranges passed.

Fix:
After sending a CRC query, the code now waits up to about 10 seconds for the reply, sending a tool-present keepalive between receives. It no longer re-sends the query while waiting.
Gene Thompson
Posts: 20
Joined: Mon Mar 14, 2022 10:06 pm
cars: 1965 Impala SS
1965 Chevelle SS
1970 Chevelle SS

Re: PcmHammer on Linux

Post by Gene Thompson »

It was the same issue as UNO. I applied the same fix and the read was successful. The problem was just as antus predicted.
The whole frame isn't there, because the Linux tty only buffers ~4095 bytes, so the receive is truncated before the checksum is computed.

I fixed it at the transport layer instead of per-device: a background pump drains the tty into a 256 KB buffer, so Receive always returns complete frames. That makes the existing OBDX read path work unchanged, and it fixes every device/interface, not just OBDX — so it may be a cleaner shared fix than an incremental read in OBDXProDevice. It runs only on Linux (runtime check), Windows path untouched.

I've also hit the slow-CRC re-query issue atshaw described (P11-style, CRC >1s read as a timeout → re-query storm). I have a "listen again before re-sending" fix from my CLI work I can bring over.

happy to sync up or agree a branch to merge back. I will push on with the stand alone logger for now.
You do not have the required permissions to view the files attached to this post.
User avatar
atshaw1994
Posts: 5
Joined: Tue Jun 30, 2026 5:53 am
cars: 2023 Kia Soul LX
1997 Chevrolet Tahoe 5.7/4L60e

Re: PcmHammer on Linux

Post by atshaw1994 »

Gene Thompson wrote: Wed Nov 11, 2026 6:04 am It was the same issue as UNO. I applied the same fix and the read was successful. The problem was just as antus predicted.
The whole frame isn't there, because the Linux tty only buffers ~4095 bytes, so the receive is truncated before the checksum is computed.

I fixed it at the transport layer instead of per-device: a background pump drains the tty into a 256 KB buffer, so Receive always returns complete frames. That makes the existing OBDX read path work unchanged, and it fixes every device/interface, not just OBDX — so it may be a cleaner shared fix than an incremental read in OBDXProDevice. It runs only on Linux (runtime check), Windows path untouched.

I've also hit the slow-CRC re-query issue atshaw described (P11-style, CRC >1s read as a timeout → re-query storm). I have a "listen again before re-sending" fix from my CLI work I can bring over.

happy to sync up or agree a branch to merge back. I will push on with the stand alone logger for now.
Very well done! :thumbup: If needed, a PR can be submitted to my repo at https://github.com/atshaw1994/PcmHammer ... p-avalonia if you'd like and I'll merge it in (discarding Claude's edits for this issue). I only have 2 changed files right now so I wouldn't be losing any work at all.

Edit: Also noticed we need to get monospaced fonts working on the avalonia side so the layout looks cleaner. The windows version (WPF) has it already. Just pointing it out because I noticed it.
User avatar
antus
Site Admin
Posts: 10111
Joined: Sat Feb 28, 2009 10:34 am
cars: TX Gemini 2L Twincam 8psi
TX Gemini SR20 18psi
Datsun 1200 Ute
Subaru Blitzen '06 EZ30 4th gen, 3.0R Spec B
Subaru WRX 2007

Re: PcmHammer on Linux

Post by antus »

Good work both. I'd like to merge this in to develop and take it as the main cross platform UI and be able to take further changes on top of that from where we are now. Don't mind who sends the pull request but I'm happy to merge it in to develop as a baseline and keep working on it from there. @gene happy for you to send a PR to atshaw then @atshaw back to the project if you're both cool with that. Then we have a pretty solid baseline for Avalonia cross platform and can build on top of it. At that point I'd like to retire uno and focus on this.
Have you read the FAQ? For lots of information and links to significant threads see here: http://pcmhacking.net/forums/viewtopic.php?f=7&t=1396
Gene Thompson
Posts: 20
Joined: Mon Mar 14, 2022 10:06 pm
cars: 1965 Impala SS
1965 Chevelle SS
1970 Chevelle SS

Re: PcmHammer on Linux

Post by Gene Thompson »

@atshaw1994 I posted a couple PR's for you to have a look at.
Started working on the logger and it still needs more work but it is coming along. Suggestions and/or corrections please let me know.
You do not have the required permissions to view the files attached to this post.
Gene Thompson
Posts: 20
Joined: Mon Mar 14, 2022 10:06 pm
cars: 1965 Impala SS
1965 Chevelle SS
1970 Chevelle SS

Re: PcmHammer on Linux

Post by Gene Thompson »

switched back to windpows so I could compare how the screens look vs linux.
I say they are pretty close.
You do not have the required permissions to view the files attached to this post.