Post Reply 
Hp prime chat terminal using arduino
07-03-2024, 05:43 PM
Post: #1
Hp prime chat terminal using arduino
Hi Guys,

I'm trying as the name suggests to create a program so i can send and receive text message's through the usb port. I have an arduino micro that supports usb hid and i'm using the nicohood hid project library. however i have no luck writing a program that wil do that. Using the usbopen() command i get (64,64) as response and using USBRecv() it returns an long ASCII beginning with (84,101,115,116... which corresponds to ''test'' which is sent by the arduino. this is the programm i'm trying to use.

Code:
EXPORT USBHIDCommunication()
BEGIN
  // Initialize graphic buffers
  DIMGROB_P(G1, 320, 240);
  RECT_P(G1, 0, 0, 320, 240, RGB(255, 255, 255));

  // Open USB HID connection
  USBOpen();

  LOCAL send_data := {1, 2, 3, 4, 5}; // Example data to send
  LOCAL received_data;
  
  // Main communication loop
  REPEAT
    // Send data
    USBSend(send_data);

    // Receive data
    received_data := USBRecv();
    
    // Display received data
    IF SIZE(received_data) > 0 THEN
      RECT_P(G1, 0, 0, 320, 240, RGB(255, 255, 255)); // Clear screen
      TEXTOUT_P("Received: " + STRING(received_data), 10, 10, 1, RGB(0, 0, 0), RGB(255, 255, 255));
      WAIT(1);
    END;

  UNTIL ISKEYDOWN(4); // Exit on pressing a key

END;

when opening the programm i get invalid input, i'm very new to HP PPL and not really sure if this code wil work or not or if anybody has done this before and is willing to share it. Does anybody have tips or ideas to help me?

thanks in advance.
Find all posts by this user
Quote this message in a reply
07-04-2024, 09:49 PM
Post: #2
RE: Hp prime chat terminal using arduino
1) Your 'TEXTOUT_P' probably fails, missing an argument.
2) You also might want to use 'G0' to see the output (vs G1~G9 that are buffers in memory and not the actual screen).
3) You probably will need to open the connection by USBOpen(Vid,Pid).

I also recommend to test that USBRecv() returns a list and not just '0'.
See encl. changes..

Code:

// 2024.0704 pretty-prime v0.3b
#pragma mode(separator(.,;) integer(h32))
EXPORT USBHIDCommunication()
BEGIN 
LOCAL send_data:={1,2,3,4,5};               // Example data to send
LOCAL received_data;

  // Initialize graphic buffers
  // DIMGROB_P(G1, 320, 240);
  // RECT_P(G1, 0, 0, 320, 240, RGB(255, 255, 255));

  // Open USB HID connection
  USBOpen();
  // USBOpen(YourVid, YourPid);

  // Main communication loop
  REPEAT 
    // Send data
    USBSend(send_data);

    // Receive data
    received_data:=USBRecv();

    // Display received data
    // IF SIZE(received_data) > 0 THEN
    IF (SIZE(received_data)>0) AND (TYPE(received_data)=6) THEN 
      // RECT_P(G1, 0, 0, 320, 240, RGB(255, 255, 255)); // Clear screen
      RECT_P();                             // Clear screen G0 by default

      // TEXTOUT_P("Received: " + STRING(received_data), 10, 10, 1, RGB(0, 0, 0), RGB(255, 255, 255));
      TEXTOUT_P("Received: "+STRING(received_data),10,10,1,RGB(0,0,0),200,RGB(255,255,255));
      WAIT(1);
    END;

  UNTIL ISKEYDOWN(4);                       // Exit on pressing a key

END;
Find all posts by this user
Quote this message in a reply
07-05-2024, 03:10 PM
Post: #3
RE: Hp prime chat terminal using arduino
Yes, you need to open the connection correctly using

USBOpen();
USBOpen(9025,32822); (yours will have different numbers)

You can find those numbers by using USBOpen() or USBRecv() when the arduino is attached.

Have a look through my old posts, I shared various types of data with arduinos.

This was the one where I had just discovered their connectability.


[url] https://www.hpmuseum.org/forum/thread-19972.html[/url]
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)