Register

Serial port questions

Discuss issues related to the fx-9860G Software Development Kit
Senior Member
Posts: 68
Joined: Tue May 08, 2012 5:40 pm

Re: Serial port questions

Postby happy » Wed Mar 27, 2013 6:32 am

Tested with an active cable and it works. Thanks Simon for your help! So this is a big hurdle crossed, next to check how much data can be transferred, whether the transfer is reliable etc.

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Serial port questions

Postby SimonLothar » Wed Mar 27, 2013 7:04 am

happy wrote:Tested with an active cable and it works. Thanks Simon for your help! So this is a big hurdle crossed, next to check how much data can be transferred, whether the transfer is reliable etc.
Good to hear. Impatiently waiting for your reports. Perhaps you could also check (after you have finished the more important tests), if the calculator can receive any data via the WiSnap. Does the calculator receive anything, if you ping the WiSnap, f. i.?
I'll be back!

Senior Member
Posts: 68
Joined: Tue May 08, 2012 5:40 pm

Re: Serial port questions

Postby happy » Wed Mar 27, 2013 11:05 am

SimonLothar wrote:Perhaps you could also check (after you have finished the more important tests), if the calculator can receive any data via the WiSnap.


Will do, that's on the list.

SimonLothar wrote:Place

while( Serial_Close( 0 ) == 5 ){};

before serialSend exits.


Btw, I had to do if (!IsEmulator()) {while( Serial_Close( 0 ) == 5 ){};}, because this was going into an infinite loop in the emulator.

Senior Member
Posts: 68
Joined: Tue May 08, 2012 5:40 pm

Re: Serial port questions

Postby happy » Thu Mar 28, 2013 7:33 pm

Progress:
1) Found out that maximum bytes I can send in one shot to WiSnap is 1524.
2) Works with 115200 baud rate.
3) I seem to have to delay sending messages one after the other. If I don't sleep for 500ms - 1s, after sending one message, it looks like messages are getting lost. (I can configure an end-of-message delimiter in WiSnap. For e.g. %. So addin can keep writing to serial port, up to 1524 bytes, and when WiSnap sees a %, it sends all the serial data in its buffer to a configured URL).
4) WiSnap is printing the HTTP response in its console, but haven't yet tested if this response is passed back on the calculator's serial port. I'm still thinking about how to implement a reliable serial receiver.

SimonLothar wrote:BTW.:
I usually implement a central input loop,
which repeatedly checks for the keyboard as well as for the the serial receive buffer.
If either source gives reason to act, the program decides accordingly.
I prefer to leave the interrupt job to the OS. It does the job very well.


Simon, I have an input loop too, but it uses GetKey(). And it gets out of the loop based on keys pressed. I should change to IsKeyDown() so that it is not blocking, to implement your idea?

Senior Member
Posts: 369
Joined: Tue Jan 03, 2012 11:24 pm
Calculators: Casio Afx 1.0, Casio fx-9860GII SD, Casio Classpad 330, Casio fx-CG20, Casio Classpad fx-CP400

Re: Serial port questions

Postby helder7 » Fri Mar 29, 2013 3:23 am

happy wrote:Progress:
3) I seem to have to delay sending messages one after the other. If I don't sleep for 500ms - 1s, after sending one message, it looks like messages are getting lost. (I can configure an end-of-message delimiter in WiSnap. For e.g. %. So addin can keep writing to serial port, up to 1524 bytes, and when WiSnap sees a %, it sends all the serial data in its buffer to a configured URL).

With fxmouse I had a similar "problem". Although it worked well with a rs232 logger, the eventghost only recognized the first command and crash with a rapid flow of bytes.
The solution that I used was Bkey_Set_RepeatTime (but sleep do the same :D ).
SiO2 + CaCO3 ----------> CaSiO3 + CO2

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Serial port questions

Postby SimonLothar » Fri Mar 29, 2013 7:12 am

happy wrote:Simon, I have an input loop too, but it uses GetKey(). And it gets out of the loop based on keys pressed. I should change to IsKeyDown() so that it is not blocking, to implement your idea?

I use PRGM_GetKey() for non-blocking keyboard requests. The SDK's IsKeyDown is incompatible with the SH-7305-based calculators. With non-blocking keyboard input you have to control the auto repeat behaviour yourself, f. i.
Code: Select all
key = PRGM_GetKey();
if ( key ){
   timestamp = RTC_GetTicks();
   while ( not RTC_Elapsed_ms( timestamp, 150 ) ){
      if ( PRGM_GetKey() != key ) break;
   };
}
I'll be back!

Senior Member
Posts: 68
Joined: Tue May 08, 2012 5:40 pm

Re: Serial port questions

Postby happy » Fri Mar 29, 2013 10:43 am

helder7 wrote:With fxmouse I had a similar "problem".


SimonLothar wrote:I use PRGM_GetKey()


Thanks

Senior Member
Posts: 68
Joined: Tue May 08, 2012 5:40 pm

Re: Serial port questions

Postby happy » Sat Mar 30, 2013 4:58 am

SimonLothar wrote:Hence the FA-122 needs a bipolar power supply (3..15V, symmetrical; typical 8-10V). If the connected device (normally a PC) does not support this, FA-122 cannot work as it is. T. i. some power supply adapter (f. i. MAX681-based) between FA-122 and connected device or a MAX232/233-based cable is needed.


Hi Simon, Since I've already bought two FA-122 cables, I wouldn't want them to go waste. Is it possible for you to post a diagram/instructions as to how to make the MAX681 based adapter? It would help a lot. (I won't be able to implement it myself, but will show it to some electronics enthusiast here to see if they can do it..)

Senior Member
User avatar
Posts: 605
Joined: Sat Sep 15, 2012 6:59 am
Location: Krautland ****
Calculators: Casio fx-7400GII, Casio fx-7400GII (SH4), Casio fx-9750GII, Casio fx-9750GII (SH4), Casio fx-9860G, Casio fx-9860G SD, Casio fx-9860G Slim, Casio fx-9860GII SD, Casio fx-9860GII SD Power Graphic 2, Casio Classpad 330 plus, Casio fx-CG20, Casio fx-CG50, Casio Classpad fx-CP400

Re: Serial port questions

Postby SimonLothar » Sat Mar 30, 2013 10:49 am

happy wrote:...Since I've already bought two FA-122 cables, I wouldn't want them to go waste. Is it possible for you to post a diagram/instructions as to how to make the MAX681 based adapter? It would help a lot. (I won't be able to implement it myself, but will show it to some electronics enthusiast here to see if they can do it..)
You need a female and a male 9-pin D-Sub connector.
Connect pins 2-2, 3-3 and 5-5 straight through.
Now you need a bipolar power supply (RS232 specification is 3..15 V).
As f. i. the MAX232 is in stock of the most retailers and the chip is very cheap, a MAX232 would do.
The MAX232 pins 2(+V) and 6(-V) can be used as bipolar power supply (10V).
According to the FA-122-converter's patent full text (http://www.pfranc.com/pclink/myidea.htm -> "My patent") the FA-122 D-sub pin DTR(4) must be connected to +V and FA-122 D-sub pin RTS(7) must be connected to -V of the bipolar power supply. The bipolar power supply's ground (in case of the MAX232 it is pin 15) must be connected to the D-sub connector's pin GND(5).
The MAX232 can pe powered by some USB-port's 5V (in case of the MAX232 Vcc must be connected to pin 16).
The five capacitors are needed too, of course.

As for diagrams refer to
viewtopic.php?f=20&t=1473
and
http://www.ti.com/lit/ds/symlink/max232.pdf.
I'll be back!

Previous

Return to Casio fx-9860 SDK

Who is online

Users browsing this forum: No registered users and 28 guests