Skip to main content
gamedev.net
🔒 Locked

Very difficult question...

Started by Muzlack 20 replies 1.4k views
Original Post
Muzlack
Muzlack
Hello everyone. I am designing a project for school. The project will require data sent through a telephone line through a Denver Instrument SWE scale. The program will recieve this information. I believe it actually sends the data through a DSL cable. I contacted someone at Denver Instruments, but I wasn''t sure if that was the right place to ask. Does anyone have any clue how I can simply get the weight of whatever is on the scale?
--Muzlack
owl
owl
Maybe their site can help. http://www.denverinstrumentusa.com/

Good luck there.
[size="2"]I like the Walrus best.
Muzlack
Muzlack
Already been there. Nothing that I could find. I believe I''ll have to write a driver to support it, but I have no clue where to start. Has anyone done this b4?
--Muzlack
owl
owl
Try this google search. I found some sites with related software. Google is your friend

[edited by - xaxa on April 4, 2003 4:16:37 PM]
[size="2"]I like the Walrus best.
kordova
kordova
quote:
Original post by xaxa
Google is your friend



Google may be your friend, sir, but don''t be making generalities!

[edited by - ChildOfKordova on October 11, 2017 10:32:23 AM]
weird
Muzlack
Muzlack
I contacted the people. Here is their email response. Is there anyone that can help me write a driver for this?

The out put connector is a RS - 232 signal level. uses 300 or 2400 baud rate selectable on front panel, see instruction manual, 8 data bits, NO parity and 1 or 2 stop bits. attached is a drawing showing the connection to a 9 pin PC port.

The balance will send by pressing print button when reading is stable or by sending a ?1 for 1 reading or a ?0 for a continuous output. any questions call or write.
--Muzlack
Coincoin
Coincoin
There is no need for a driver here.

It is a simple serial interface. In that case... just plug it into your computer using a standard serial RS232 cable and
interface with it by opening "COM1" or "COM2" files.

A quick test would be to try that in hyperterminal. It comes bundled with windows in accessories->communications->hyperterminal. Start it... and create a new connection and specify COM1 or COM2 as the port. Set the baud rate, data bits, parity, stop bits then connect. Just type ?0 and it should work.
If it doesn't try with COM2 and double check the port settings.


---
When programming your own programm, you may need to use SetCommState to set baud rate after opening com1 or com2. It's a standard WIN32API function. Then just write to the file "?0" and then read from the file for the results. As simple as that.

______________________________
Oooh, you found the horadric cube!


[edited by - Coincoin on April 20, 2003 3:46:16 AM]
antareus
antareus
quote:
Original post by Anonymous Poster
What does it have to do with games development?

Nothing, which is why its on the General Programming board.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Muzlack
Muzlack
Thanks alot! Unfortunately, I''ll have to do that tomorrow, at school, since these bad boys cost 1000s of dollars.
--Muzlack
Muzlack
Muzlack
It is. It''s the ultimate copy protection. When you download the game for free, you also have to purchase one of these scales. When you mail us the $, we''ll send you a cube that weighs exactly 1.04561832 grams. Unless you have the scale and the cube, you can''t play the game!

I''m totally joking, btw.
--Muzlack
Muzlack
Muzlack
problem. Turns out this is a 6 pin rs-232 port. Is it possible to get one with 6 pins on one side and a standard (8 pins I think) on the other side of the cable? I don''t have one yet.
--Muzlack
Coincoin
Coincoin
Looks like you will have to use this chart after all.

Either find a 9 pin to 6 pin(?) (never heard of that)... or try to buy the same connector as the scale then make your own cable using the chart they gave you.

______________________________
Oooh, you found the horadric cube!
Muzlack
Muzlack
Will I still be able to use the above method? The logic behind this doesn''t make much sense anymore.
--Muzlack
Muzlack
Muzlack
I was wrong. It''s an RJ-45 (telephone cable) does it work the same way?
--Muzlack
MOVSW
MOVSW
quote:
Original post by Muzlack
I was wrong. It''s an RJ-45 (telephone cable) does it work the same way?


RJ-45 is not a telephone cable, but a plug that is used for common LAN. RJ-11 is the phone cable connector.
Muzlack
Muzlack
Clearly, I do not know my cable types. It''s the kind you''d plug a phone into the wall with,
--Muzlack
Coincoin
Coincoin
It doesnt change anything with the logic.

RJ45 is in fact often used for serial cable. Those RJ45 to RS232 cable are also commonly called console cables. They are widely used on Cisco routers and switches. I guess you can find them in any computer shop... or try cisco.com. Try a place where they can refund in case it''s not the right cable.

The program''s logic stays the same... open the COM1 or COM2 files (that is... files litteraly named COM1 and COM2) and write / read from these. But as I said... test with hyperterminal first.

______________________________
Oooh, you found the horadric cube!
Muzlack
Muzlack
sorry to bump this thread. I just finished the cable yesterday. Had lots of problems, but my Hyperterminal test started working today! So, to get a recieve information by programming, I'd do something like:

FILE *fp=fopen("COM1", "r");
SetCommState(300);
fprintf(fp,"?0");
fgets(fp);

Something like that? Sorry. This is all indifferent to me. It's good practice for something I haven't done, but I just don' understand I suppose.

[edited by - Muzlack on June 2, 2003 5:52:22 PM]
--Muzlack
Muzlack
Muzlack
Been reading up on-line. Too bad I need the scale (at school) to test this. Here''s my code.
Does it look right? The project is due on friday.



#include <stdio.h>
#include <stdlib.h>
#include <ddraw.h>
#include <dinput.h>
#include <memory.h>

#include <mmsystem.h>
#include <vector>
#include <string>
using namespace std;

int main() {
string portname="//./COM1";

DCB m_dcb; //get current port settings

BOOL b; //bools for checking

//open our port

HANDLE hComm = CreateFile(portname.c_str(), GENERIC_READ | GENERIC_WRITE,0,0,OPEN_EXISTING,
0,0);
if(hComm==INVALID_HANDLE_VALUE) { //handle errors.

printf("PROBLEM. #1\n");
return (1);
}

b=GetCommState(hComm,&m_dcb);
if(b==0) {
printf("PROBLEM. #2\n");
CloseHandle(hComm);
return(1);
}

//fill in data.

m_dcb.BaudRate=300;
m_dcb.ByteSize=8;
m_dcb.Parity=NOPARITY;
m_dcb.StopBits=ONESTOPBIT;
m_dcb.fBinary=TRUE;
m_dcb.fDsrSensitivity=FALSE;
m_dcb.fParity=FALSE;
m_dcb.fOutX=false;
m_dcb.fInX=false;
m_dcb.fNull=false;
m_dcb.fAbortOnError=TRUE;
m_dcb.fOutxCtsFlow=FALSE;
m_dcb.fOutxDsrFlow=false;
m_dcb.fDtrControl=DTR_CONTROL_DISABLE;
m_dcb.fDsrSensitivity=false;
m_dcb.fRtsControl=RTS_CONTROL_DISABLE;

b=SetCommState(hComm,&m_dcb);
if(b==0) {
printf("PROBLEM. #3\n");
CloseHandle(hComm);
return(1);
}
printf("Succesfully initialized stuff. I hope.\n");
BYTE rx;
BYTE resp=0;
DWORD dwBytesTransferred=0;
int i=0;
char s[50];
while(1) {
for(int z=0;z<500;z++) {

if(ReadFile(hComm,℞,1,&dwBytesTransferred,0)) {
if(dwBytesTransferred==1) {
resp=rx;
s[i]=rx;
} else {
break;
}
}
}
i=0;
printf("TEXT RECIEVED: %s\n",s);

}
CloseHandle(hComm);
return(0);
}

--Muzlack

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.