j0h

Bash_PLC_IO

j0h
Mar 18th, 2026
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/bin/bash
  2. # trying to make the PLC run on my phone
  3. PORT="/dev/ttyACM0"
  4. BAUD=9600
  5.  
  6. echo "[*] Configue $PORT ..."
  7. stty -F "$PORT" "$BAUD" cs8 -cstopb parenb -parodd raw -echo -hupcl
  8.  
  9. # keep it open
  10. exec 3>"$PORT"
  11.  
  12. send_frame() {
  13. local frame="$1"
  14. printf '[TX] '
  15. printf '%b' "$frame" | xxd -p -c 256 | sed 's/../& /g'
  16. printf '%b' "$frame" >&3
  17. sleep 0.15
  18. }
  19.  
  20. echo "[*] ON sequence"
  21. # verified raw IO
  22. send_frame '\x05FF0Wy000012A\r'
  23. send_frame '\x05FF0Wy000112B\r'
  24. send_frame '\x05FF0Wy0002128\r'
  25. send_frame '\x05FF0Wy0003129\r'
  26. send_frame '\x05FF0Wy000412E\r'
  27. send_frame '\x05FF0Wy000512F\r'
  28. send_frame '\x05FF0Wy000612C\r'
  29. send_frame '\x05FF0Wy000712D\r'
  30.  
  31. sleep 5
  32.  
  33. echo "[*] OFF sequence"
  34. # verified raw IO
  35. send_frame '\x05FF0Wy000702C\r'
  36. send_frame '\x05FF0Wy000602D\r'
  37. send_frame '\x05FF0Wy000502E\r'
  38. send_frame '\x05FF0Wy000402F\r'
  39. send_frame '\x05FF0Wy0003028\r'
  40. send_frame '\x05FF0Wy0002029\r'
  41. send_frame '\x05FF0Wy000102A\r'
  42. send_frame '\x05FF0Wy000002B\r'
  43.  
  44. # Close once at the end
  45. exec 3>&-
  46. # still cant exec raw on phone.
  47.  
Advertisement
Add Comment
Please, Sign In to add comment