43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
|
|
#!/usr/bin/env python3
|
||
|
|
import sys
|
||
|
|
import os
|
||
|
|
|
||
|
|
pdf_path = "LSPi_Project/doc/ÁºÉ½Pi¿ª·¢°å.pdf"
|
||
|
|
|
||
|
|
# Simple binary read and extract text
|
||
|
|
try:
|
||
|
|
with open(pdf_path, 'rb') as f:
|
||
|
|
data = f.read()
|
||
|
|
|
||
|
|
# Extract printable ASCII characters
|
||
|
|
text_chars = []
|
||
|
|
for byte in data:
|
||
|
|
if 32 <= byte < 127: # Printable ASCII
|
||
|
|
text_chars.append(chr(byte))
|
||
|
|
elif byte == 10 or byte == 13: # Newline
|
||
|
|
text_chars.append('\n')
|
||
|
|
|
||
|
|
text = ''.join(text_chars)
|
||
|
|
|
||
|
|
# Find potentially useful sections
|
||
|
|
lines = text.split('\n')
|
||
|
|
useful_lines = []
|
||
|
|
keywords = ['pin', 'gpio', 'uart', 'i2c', 'spi', 'adc', 'timer', 'usart', 'tx', 'rx', 'scl', 'sda', 'miso', 'mosi', 'sck', 'cs', 'pa', 'pb', 'pc', 'pd', 'pe', 'pf', 'pg']
|
||
|
|
|
||
|
|
for line in lines:
|
||
|
|
line_lower = line.lower()
|
||
|
|
if any(keyword in line_lower for keyword in keywords):
|
||
|
|
useful_lines.append(line)
|
||
|
|
|
||
|
|
print("=== Useful information from PDF ===")
|
||
|
|
for i, line in enumerate(useful_lines[:100]):
|
||
|
|
print(f"{i+1}: {line}")
|
||
|
|
|
||
|
|
# Also show some general content
|
||
|
|
print("\n=== First 2000 characters of PDF content ===")
|
||
|
|
print(text[:2000])
|
||
|
|
|
||
|
|
except Exception as e:
|
||
|
|
print(f"Error: {e}")
|
||
|
|
import traceback
|
||
|
|
traceback.print_exc()
|