GeekMagicClock / HelloCubic-V2

Update version of HelloCubic with Senor
21 stars 1 forks source link

Source code? #1

Open skorokithakis opened 2 weeks ago

skorokithakis commented 2 weeks ago

Please post the source code as well so we can improve it.

CodeByAidan commented 2 weeks ago

So much for an open-source developer platform... Instead uses it as a file host....

CodeByAidan commented 2 weeks ago

I just looked at this guy's profile, for any code or anything other than his project. He doesn't upload any source code. You can check for yourself using this neat GitHub search syntax:

owner:GeekMagicClock -repo:GeekMagicClock/GeekMagic-S3 -path:*.md -path:*.ini -path:*.csv -path:*.gitignore -path:*.bin -path:txt -path:.gitattributes

where - is the same as NOT, just better syntax.

This looks for the user GeekMagicClock (owner of the repository) then does not look at his project called GeekMagic-S3 and then ignores anything that's not a real programming language.

😕

CodeByAidan commented 2 weeks ago

Was able to extract readable strings from the latest binary firmware file (firmware_V3.2.17EN.bin) using:

use std::fs::File;
use std::io::{self, Read};

fn main() -> io::Result<()> {
    let file_path = "firmware_V3.2.17EN.bin";
    let mut file = File::open(file_path)?;
    let mut buffer = Vec::new();
    file.read_to_end(&mut buffer)?;
    extract_strings(&buffer);
    Ok(())
}

fn extract_strings(buffer: &[u8]) {
    let mut current_string = String::new();
    for &byte in buffer {
        if byte.is_ascii_graphic() || byte == b' ' {
            current_string.push(byte as char);
        } else {
            if current_string.len() > 3 {
                println!("{}", current_string);
            }
            current_string.clear();
        }
    }
    if current_string.len() > 3 {
        println!("{}", current_string);
    }
}

ChatGPT translated this into Java:

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

public class BinaryFileStringExtractor {

    public static void main(String[] args) {
        File file = new File("firmware_V3.2.17EN.bin");
        try {
            extractStrings(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void extractStrings(File file) throws IOException {
        try (FileInputStream fis = new FileInputStream(file)) {
            StringBuilder builder = new StringBuilder();
            int character;
            while ((character = fis.read()) != -1) {
                if (character >= 32 && character <= 126) {
                    builder.append((char) character);
                } else {
                    if (builder.length() > 3) {
                        System.out.println(builder.toString());
                    }
                    builder.setLength(0);
                }
            }
        }
    }
}

Result:

https://gist.githubusercontent.com/CodeByAidan/d5e86de1225ef2fff4f13cc9e0256515/raw/6515508f58074f9a3d4b229f94a8b8218795412d/out.txt

(would not recommend clicking on the GitHub Gist non-raw version.... Your browser might not handle 20k lines of txt... beware! - https://gist.github.com/CodeByAidan/d5e86de1225ef2fff4f13cc9e0256515)

GeekMagicClock commented 2 weeks ago

If you are looking for open source projects, we recommend that you refer to this. Other projects are under commercial consideration and have no open source plans.

https://github.com/GeekMagicClock/GeekMagic-S3

CodeByAidan commented 2 weeks ago

@GeekMagicClock Hello, thanks for your quick reply! Is this project, "GeekMagic-S3", related to this product, the "HelloCubic-V2", or is this related to any other product, or is this simply just a personal project for you?

您好,感謝您的快速回覆!GeekMagic-S3」這個專案是否與「HelloCubic-V2」這個產品有關,或是與其他產品有關,還是這只是您的個人專案?

GeekMagicClock commented 2 weeks ago

Hi @CodeByAidan It is an independent project and has nothing to do with other projects. You can simply think of it as an open source development board, display what ever you want.